Beispiel #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
Beispiel #2
0
def IterateOverDirectSites(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 ['GEN', 'GEN2']:
        if lazylibrarian.CONFIG[prov]:
            if ProviderIsBlocked(prov):
                logger.debug('[IterateOverDirectSites] - %s %s is BLOCKED' %
                             (lazylibrarian.CONFIG[prov + '_HOST'],
                              lazylibrarian.CONFIG[prov + '_SEARCH']))
            else:
                logger.debug('[IterateOverDirectSites] - %s %s' %
                             (lazylibrarian.CONFIG[prov + '_HOST'],
                              lazylibrarian.CONFIG[prov + '_SEARCH']))
                results, error = GEN(book, prov)
                if error:
                    BlockProvider(prov, error)
                else:
                    resultslist += results
                    providers += 1

    return resultslist, providers
Beispiel #3
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
Beispiel #4
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