Exemple #1
0
def test_provider(name):
    book = {'searchterm': 'Agatha+Christie', 'library': 'eBook'}
    if name == 'TPB':
        return TPB(book, test=True), "Pirate Bay"
    if name == 'KAT':
        return KAT(book, test=True), "KickAss Torrents"
    if name == 'ZOO':
        return ZOO(book, test=True), "Zooqle"
    if name == 'LIME':
        return LIME(book, test=True), "LimeTorrents"
    if name == 'TDL':
        return TDL(book, test=True), "TorrentDownloads"
    if name == 'GEN':
        return GEN(book, prov='GEN', test=True), "LibGen 1"
    if name == 'GEN2':
        return GEN(book, prov='GEN2', test=True), "LibGen 2"
    if name.startswith('rss['):
        try:
            prov = name.split('[')[1].split(']')[0]
            for provider in lazylibrarian.RSS_PROV:
                if provider['NAME'] == 'RSS_%s' % prov and provider['HOST']:
                    return RSS(provider['HOST'], provider['NAME'],
                               provider['DLPRIORITY']), provider['NAME']
        except IndexError:
            pass

    # for torznab/newznab try book search if enabled, fall back to general search
    book.update({
        'authorName': 'Agatha Christie',
        'bookName': 'Poirot',
        'bookSub': ''
    })
    if name.startswith('torznab['):
        try:
            prov = name.split('[')[1].split(']')[0]
            for provider in lazylibrarian.TORZNAB_PROV:
                if provider['NAME'] == 'Torznab%s' % prov and provider['HOST']:
                    return NewzNabPlus(book, provider, 'book', 'torznab',
                                       True), provider['NAME']
        except IndexError:
            pass
    if name.startswith('newznab['):
        try:
            prov = name.split('[')[1].split(']')[0]
            for provider in lazylibrarian.NEWZNAB_PROV:
                if provider['NAME'] == 'Newznab%s' % prov and provider['HOST']:
                    return NewzNabPlus(book, provider, 'book', 'nzb',
                                       True), provider['NAME']
        except IndexError:
            pass
    msg = "Unknown provider [%s]" % name
    logger.error(msg)
    return False, msg
def IterateOverTorrentSites(book=None, searchType=None):

    resultslist = []
    providers = 0
    if searchType != 'mag' and searchType != 'general':
        authorname, bookname = get_searchterm(book, searchType)
        book['searchterm'] = authorname + ' ' + bookname

    if lazylibrarian.CONFIG['KAT']:
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.CONFIG['KAT_HOST'])
        resultslist += KAT(book)
    if lazylibrarian.CONFIG['TPB']:
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.CONFIG['TPB_HOST'])
        resultslist += TPB(book)
    if lazylibrarian.CONFIG['ZOO']:
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.CONFIG['ZOO_HOST'])
        resultslist += ZOO(book)
    if lazylibrarian.CONFIG['EXTRA']:
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.CONFIG['EXTRA_HOST'])
        resultslist += EXTRA(book)
    if lazylibrarian.CONFIG['TDL']:
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.CONFIG['TDL_HOST'])
        resultslist += TDL(book)
    if lazylibrarian.CONFIG['GEN']:
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.CONFIG['GEN_HOST'])
        resultslist += GEN(book)
    if lazylibrarian.CONFIG['LIME']:
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.CONFIG['LIME_HOST'])
        resultslist += LIME(book)

    return resultslist, providers
Exemple #3
0
def IterateOverTorrentSites(book=None, searchType=None):
    resultslist = []
    providers = 0
    if searchType != 'mag' and searchType != 'general':
        authorname, bookname = get_searchterm(book, searchType)
        book['searchterm'] = authorname + ' ' + bookname

    for prov in ['KAT', 'WWT', 'TPB', 'ZOO', 'TDL', 'LIME']:
        if lazylibrarian.CONFIG[prov]:
            if ProviderIsBlocked(prov):
                logger.debug('[IterateOverTorrentSites] - %s is BLOCKED' %
                             lazylibrarian.CONFIG[prov + '_HOST'])
            else:
                logger.debug('[IterateOverTorrentSites] - %s' %
                             lazylibrarian.CONFIG[prov + '_HOST'])
                if prov == 'KAT':
                    results, error = KAT(book)
                elif prov == 'WWT':
                    results, error = WWT(book)
                elif prov == 'TPB':
                    results, error = TPB(book)
                elif prov == 'ZOO':
                    results, error = ZOO(book)
                # elif prov == 'EXTRA':
                #    results, error = EXTRA(book)
                elif prov == 'TDL':
                    results, error = TDL(book)
                elif prov == 'LIME':
                    results, error = LIME(book)
                else:
                    results = ''
                    error = ''
                    logger.error(
                        'IterateOverTorrentSites called with unknown provider [%s]'
                        % prov)

                if error:
                    BlockProvider(prov, error)
                else:
                    resultslist += results
                    providers += 1

    return resultslist, providers
Exemple #4
0
def IterateOverTorrentSites(book=None, searchType=None):

    resultslist = []
    providers = 0
    if searchType != 'mag':
        authorname, bookname = get_searchterm(book, searchType)
        book['searchterm'] = authorname + ' ' + bookname

    if (lazylibrarian.KAT):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' % lazylibrarian.KAT_HOST)
        resultslist += KAT(book)
    if (lazylibrarian.TPB):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' % lazylibrarian.TPB_HOST)
        resultslist += TPB(book)
    if (lazylibrarian.ZOO):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' % lazylibrarian.ZOO_HOST)
        resultslist += ZOO(book)
    if (lazylibrarian.EXTRA):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.EXTRA_HOST)
        resultslist += EXTRA(book)
    if (lazylibrarian.TDL):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' % lazylibrarian.TDL_HOST)
        resultslist += TDL(book)
    if (lazylibrarian.GEN):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' % lazylibrarian.GEN_HOST)
        resultslist += GEN(book)
    if (lazylibrarian.LIME):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - %s' %
                     lazylibrarian.LIME_HOST)
        resultslist += LIME(book)

    return resultslist, providers
Exemple #5
0
def IterateOverTorrentSites(book=None, searchType=None):

    resultslist = []
    providers = 0
    if (lazylibrarian.KAT):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - KAT')
        resultslist += KAT(book)
    if (lazylibrarian.TPB):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - TPB')
        resultslist += TPB(book)
    if (lazylibrarian.ZOO):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - ZOO')
        resultslist += ZOO(book)
    if (lazylibrarian.TDL):
        providers += 1
        logger.debug('[IterateOverTorrentSites] - TDL')
        resultslist += TDL(book)

    return resultslist, providers
Exemple #6
0
def test_provider(name, host=None, api=None):
    logger.debug("Testing provider %s" % name)
    book = {'searchterm': 'Agatha+Christie', 'library': 'eBook'}
    if name == 'TPB':
        if host:
            lazylibrarian.CONFIG['TPB_HOST'] = host
        return TPB(book, test=True), "Pirate Bay"
    if name == 'KAT':
        if host:
            lazylibrarian.CONFIG['KAT_HOST'] = host
        return KAT(book, test=True), "KickAss Torrents"
    if name == 'ZOO':
        if host:
            lazylibrarian.CONFIG['ZOO_HOST'] = host
        return ZOO(book, test=True), "Zooqle"
    if name == 'LIME':
        if host:
            lazylibrarian.CONFIG['LIME_HOST'] = host
        return LIME(book, test=True), "LimeTorrents"
    if name == 'TDL':
        if host:
            lazylibrarian.CONFIG['TDL_HOST'] = host
        return TDL(book, test=True), "TorrentDownloads"
    if name == 'GEN':
        if host:
            lazylibrarian.CONFIG['GEN_HOST'] = host
        if api:
            lazylibrarian.CONFIG['GEN_SEARCH'] = api
        return GEN(book, prov='GEN', test=True), "LibGen 1"
    if name == 'GEN2':
        if host:
            lazylibrarian.CONFIG['GEN2_HOST'] = host
        if api:
            lazylibrarian.CONFIG['GEN2_SEARCH'] = api
        return GEN(book, prov='GEN2', test=True), "LibGen 2"
    if name.startswith('rss_'):
        try:
            prov = name.split('_')[1]
            for provider in lazylibrarian.RSS_PROV:
                if provider['NAME'] == 'RSS_%s' % prov:
                    if not host:
                        host = provider['HOST']
                    if 'goodreads' in host and 'list_rss' in host:
                        return GOODREADS(host,
                                         provider['NAME'],
                                         provider['DLPRIORITY'],
                                         provider['DISPNAME'],
                                         test=True), provider['DISPNAME']
                    elif 'goodreads' in host and '/list/show/' in host:
                        # goodreads listopia
                        return LISTOPIA(host,
                                        provider['NAME'],
                                        provider['DLPRIORITY'],
                                        provider['DISPNAME'],
                                        test=True), provider['DISPNAME']
                    else:
                        return RSS(host,
                                   provider['NAME'],
                                   provider['DLPRIORITY'],
                                   provider['DISPNAME'],
                                   test=True), provider['DISPNAME']
        except IndexError:
            pass

    # for torznab/newznab get capabilities first, unless locked,
    # then try book search if enabled, fall back to general search
    book.update({
        'authorName': 'Agatha Christie',
        'bookName': 'Poirot',
        'bookSub': ''
    })
    if name.startswith('torznab_'):
        try:
            prov = name.split('_')[1]
            for provider in lazylibrarian.TORZNAB_PROV:
                if provider['NAME'] == 'Torznab%s' % prov:
                    if provider['MANUAL']:
                        logger.debug("Capabilities are set to manual for %s" %
                                     provider['NAME'])
                    else:
                        provider = get_capabilities(provider, force=True)
                    if host:
                        provider['HOST'] = host
                    if api:
                        provider['API'] = api
                    if provider['BOOKSEARCH']:
                        success, errorMsg = NewzNabPlus(
                            book, provider, 'book', 'torznab', True)
                        if not success:
                            if cancelSearchType('book', errorMsg, provider):
                                success, _ = NewzNabPlus(
                                    book, provider, 'general', 'torznab', True)
                    else:
                        success, _ = NewzNabPlus(book, provider, 'general',
                                                 'torznab', True)
                    return success, provider['DISPNAME']
        except IndexError:
            pass
    if name.startswith('newznab_'):
        try:
            prov = name.split('_')[1]
            for provider in lazylibrarian.NEWZNAB_PROV:
                if provider['NAME'] == 'Newznab%s' % prov:
                    if provider['MANUAL']:
                        logger.debug("Capabilities are set to manual for %s" %
                                     provider['NAME'])
                    else:
                        provider = get_capabilities(provider, force=True)
                    if host:
                        provider['HOST'] = host
                    if api:
                        provider['API'] = api
                    if provider['BOOKSEARCH']:
                        success, errorMsg = NewzNabPlus(
                            book, provider, 'book', 'newznab', True)
                        if not success:
                            if cancelSearchType('book', errorMsg, provider):
                                success, _ = NewzNabPlus(
                                    book, provider, 'general', 'newznab', True)
                    else:
                        success, _ = NewzNabPlus(book, provider, 'general',
                                                 'newznab', True)
                    return success, provider['DISPNAME']
        except IndexError:
            pass
    msg = "Unknown provider [%s]" % name
    logger.error(msg)
    return False, msg
Exemple #7
0
def test_provider(name, host=None, api=None):
    book = {'searchterm': 'Agatha+Christie', 'library': 'eBook'}
    if name == 'TPB':
        if host:
            lazylibrarian.CONFIG['TPB_HOST'] = host
        return TPB(book, test=True), "Pirate Bay"
    if name == 'KAT':
        if host:
            lazylibrarian.CONFIG['KAT_HOST'] = host
        return KAT(book, test=True), "KickAss Torrents"
    if name == 'ZOO':
        if host:
            lazylibrarian.CONFIG['ZOO_HOST'] = host
        return ZOO(book, test=True), "Zooqle"
    if name == 'LIME':
        if host:
            lazylibrarian.CONFIG['LIME_HOST'] = host
        return LIME(book, test=True), "LimeTorrents"
    if name == 'TDL':
        if host:
            lazylibrarian.CONFIG['TDL_HOST'] = host
        return TDL(book, test=True), "TorrentDownloads"
    if name == 'GEN':
        if host:
            lazylibrarian.CONFIG['GEN_HOST'] = host
        if api:
            lazylibrarian.CONFIG['GEN_SEARCH'] = api
        return GEN(book, prov='GEN', test=True), "LibGen 1"
    if name == 'GEN2':
        if host:
            lazylibrarian.CONFIG['GEN2_HOST'] = host
        if api:
            lazylibrarian.CONFIG['GEN2_SEARCH'] = api
        return GEN(book, prov='GEN2', test=True), "LibGen 2"
    if name.startswith('rss_'):
        try:
            prov = name.split('_')[1]
            for provider in lazylibrarian.RSS_PROV:
                if provider['NAME'] == 'RSS_%s' % prov:
                    if not host:
                        host = provider['HOST']
                    if 'goodreads' in host and 'list_rss' in host:
                        return GOODREADS(host, provider['NAME'], provider['DLPRIORITY'],
                                         test=True), provider['DISPNAME']
                    elif 'goodreads' in host and '/list/show/' in host:
                        # goodreads listopia
                        return LISTOPIA(host, provider['NAME'], provider['DLPRIORITY'],
                                        test=True), provider['DISPNAME']
                    else:
                        return RSS(host, provider['NAME'], provider['DLPRIORITY'],
                                   test=True), provider['DISPNAME']
        except IndexError:
            pass

    # for torznab/newznab try book search if enabled, fall back to general search
    book.update({'authorName': 'Agatha Christie', 'bookName': 'Poirot', 'bookSub': ''})
    if name.startswith('torznab_'):
        try:
            prov = name.split('_')[1]
            for provider in lazylibrarian.TORZNAB_PROV:
                if provider['NAME'] == 'Torznab%s' % prov:
                    if host:
                        provider['HOST'] = host
                    if api:
                        provider['API'] = api
                    return NewzNabPlus(book, provider, 'book', 'torznab', True), provider['DISPNAME']
        except IndexError:
            pass
    if name.startswith('newznab_'):
        try:
            prov = name.split('_')[1]
            for provider in lazylibrarian.NEWZNAB_PROV:
                if provider['NAME'] == 'Newznab%s' % prov:
                    if host:
                        provider['HOST'] = host
                    if api:
                        provider['API'] = api
                    return NewzNabPlus(book, provider, 'book', 'nzb', True), provider['DISPNAME']
        except IndexError:
            pass
    msg = "Unknown provider [%s]" % name
    logger.error(msg)
    return False, msg