示例#1
0
def checkFolder():
    
    with postprocessor_lock:

        myDB = db.DBConnection()
        snatched = myDB.select('SELECT * from snatched WHERE Status="Snatched"')

        for album in snatched:
        
            if album['FolderName']:
                
                # We're now checking sab config options after sending to determine renaming - but we'll keep the
                # iterations in just in case we can't read the config for some reason

                nzb_album_possibilities = [ album['FolderName'],
                                            sab_replace_dots(album['FolderName']),
                                            sab_replace_spaces(album['FolderName']),
                                            sab_replace_spaces(sab_replace_dots(album['FolderName']))
                                        ]

                torrent_album_path = os.path.join(headphones.DOWNLOAD_TORRENT_DIR, album['FolderName']).encode(headphones.SYS_ENCODING)

                for nzb_folder_name in nzb_album_possibilities:
                    
                    nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, nzb_folder_name).encode(headphones.SYS_ENCODING)

                    if os.path.exists(nzb_album_path):
                        logger.debug('Found %s in NZB download folder. Verifying....' % album['FolderName'])
                        verify(album['AlbumID'], nzb_album_path, album['Kind'])

                if os.path.exists(torrent_album_path):
                    logger.debug('Found %s in torrent download folder. Verifying....' % album['FolderName'])
                    verify(album['AlbumID'], torrent_album_path, album['Kind'])
def checkFolder():
    
    with postprocessor_lock:

        myDB = db.DBConnection()
        snatched = myDB.select('SELECT * from snatched WHERE Status="Snatched"')

        for album in snatched:
        
            if album['FolderName']:
                
                # Need to check for variations due to sab renaming. Ideally we'd check the sab config via api to 
                # figure out which options are checked, but oh well

                nzb_album_possibilities = [ album['FolderName'],
                                            sab_replace_dots(album['FolderName']),
                                            sab_replace_spaces(album['FolderName']),
                                            sab_replace_dots(sab_replace_spaces(album['FolderName']))
                                        ]

                torrent_album_path = os.path.join(headphones.DOWNLOAD_TORRENT_DIR, album['FolderName']).encode(headphones.SYS_ENCODING)

                for nzb_folder_name in nzb_album_possibilities:
                    
                    nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, nzb_folder_name).encode(headphones.SYS_ENCODING)

                    if os.path.exists(nzb_album_path):
                        logger.debug('Found %s in NZB download folder. Verifying....' % album['FolderName'])
                        verify(album['AlbumID'], nzb_album_path)

                if os.path.exists(torrent_album_path):
                    logger.debug('Found %s in torrent download folder. Verifying....' % album['FolderName'])
                    verify(album['AlbumID'], torrent_album_path)
示例#3
0
def checkFolder():

    with postprocessor_lock:

        myDB = db.DBConnection()
        snatched = myDB.select(
            'SELECT * from snatched WHERE Status="Snatched"')

        for album in snatched:
            logger.debug(u"Processing %s" % album['FolderName'])

            if album['FolderName']:
                if album['Kind'] == 'nzb':
                    # We're now checking sab config options after sending to determine renaming - but we'll keep the
                    # iterations in just in case we can't read the config for some reason

                    nzb_album_possibilities = [
                        album['FolderName'],
                        sab_replace_dots(album['FolderName']),
                        sab_replace_spaces(album['FolderName']),
                        sab_replace_spaces(
                            sab_replace_dots(album['FolderName']))
                    ]

                    for nzb_folder_name in nzb_album_possibilities:

                        nzb_album_path = os.path.join(
                            headphones.DOWNLOAD_DIR,
                            nzb_folder_name).encode(headphones.SYS_ENCODING,
                                                    'replace')

                        if os.path.exists(nzb_album_path):
                            logger.debug(
                                'Found %s in NZB download folder. Verifying....'
                                % album['FolderName'])
                            verify(album['AlbumID'], nzb_album_path, 'nzb')

                if album['Kind'] == 'torrent':
                    if 'hash:' in album['FolderName']:
                        torrent_name, torrent_hash = album['FolderName'].split(
                            "_hash:")
                        torrent_folder_name = transmission.getTorrentFolder(
                            torrent_hash)
                        if torrent_folder_name:
                            torrent_album_path = os.path.join(
                                headphones.DOWNLOAD_TORRENT_DIR,
                                torrent_folder_name)
                        else:
                            logger.debug(
                                u"Could not find torrent %s in Transmission queue using hash search, might have been deleted? Retry downloading same torrent again or clear Headphone snatch history"
                                % torrent_name)
                            torrent_folder_name = transmission.getTorrentFolder(
                                torrent_name)
                            if torrent_folder_name:
                                torrent_album_path = os.path.join(
                                    headphones.DOWNLOAD_TORRENT_DIR,
                                    torrent_folder_name)
                            else:
                                logger.info(
                                    u"Could not find torrent %s in Transmission queue using name search, might have been deleted? Retry downloading same torrent again or clear Headphone snatch history"
                                    % torrent_name)
                                torrent_album_path = "nonexistent torrent"
                    else:
                        torrent_album_path = os.path.join(
                            headphones.DOWNLOAD_TORRENT_DIR,
                            album['FolderName']).encode(
                                headphones.SYS_ENCODING, 'replace')

                    if os.path.exists(torrent_album_path):
                        logger.debug(
                            'Found %s in torrent download folder. Verifying....'
                            % torrent_folder_name)
                        verify(album['AlbumID'], torrent_album_path, 'torrent')
                    else:
                        logger.debug("Path does not exists %s " %
                                     torrent_album_path)