Beispiel #1
0
    def test_Reversal(self):
        cfg.logger.info(
            f"Running {self.__class__.__name__}: {self._testMethodName}")
        localIds = ['A', 'B', 'C', 'D', 'E']
        remoteIds = ['E', 'D', 'C', 'B', 'A']

        correct = [('E', 4), ('D', 3), ('C', 2), ('B', 1), ('A', 0)]

        result = smartSyncNewOrder(localIds, remoteIds)
        self.assertEqual(result, correct)
Beispiel #2
0
    def test_3(self):
        cfg.logger.info(
            f"Running {self.__class__.__name__}: {self._testMethodName}")
        localIds = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
        remoteIds = ['A', '1', 'C', 'B', '2', 'F']

        correct = [('A', 0), ('1', None), ('C', 2), ('D', 3), ('E', 4),
                   ('B', 1), ('2', None), ('F', 5), ('G', 6)]

        result = smartSyncNewOrder(localIds, remoteIds)
        self.assertEqual(result, correct)
Beispiel #3
0
    def test_LocalDeleteAll(self):
        cfg.logger.info(
            f"Running {self.__class__.__name__}: {self._testMethodName}")
        localIds = []
        remoteIds = ['A', '1', 'C', 'B', '2', 'F']

        correct = [('A', None), ('1', None), ('C', None), ('B', None),
                   ('2', None), ('F', None)]

        result = smartSyncNewOrder(localIds, remoteIds)
        self.assertEqual(result, correct)
Beispiel #4
0
def smartSync(plPath):
    '''
    Syncs to remote playlist however will Not delete local songs (will reorder). Songs not in remote (ie ones deleted) 
    will be after the song they are currently after in local
    Example 1
        Local order: A B C D 
        Remote order: A 1 B C 2

        Local becomes: A 1 B C D 2

        notice D was removed from remote but is still after C in Local
    
    Example 2
        Local order: A B C D 
        Remote order: A 1 C B 2

        Local becomes: A 1 C D B 2

        notice C and B where swapped and D was deleted from Remote
    
    see test_smartSyncNewOrder in tests.py for more examples
    '''
    cfg.logger.info("Smart Syncing...")
    correctStateCorruption(plPath)


    with shelve.open(f"{plPath}/{cfg.metaDataName}", 'c',writeback=True) as metaData:
        url = metaData["url"]
        localIds = metaData["ids"]

    remoteIds = getIDs(url)


    newOrder = smartSyncNewOrder(localIds,remoteIds)

    editPlaylist(plPath,newOrder)