Ejemplo n.º 1
0
                                     stream=True,
                                     headers=headers)
                except Exception, e:
                    logger.warn('Error fetching data from %s: %s' % (site, e))
                    return "fail"
            else:
                logger.warn(
                    '[32P] Unable to authenticate using existing RSS Feed given. Make sure that you have provided a CURRENT feed from 32P'
                )
                return "fail"
        else:
            return "fail"

    if str(r.status_code) == '403':
        #retry with the alternate torrent link.
        url = helpers.torrent_create('KAT', linkit, True)
        try:
            r = requests.get(url,
                             params=payload,
                             verify=verify,
                             stream=True,
                             headers=headers)

        except Exception, e:
            return "fail"

    if str(r.status_code) != '200':
        logger.warn('Unable to download torrent from ' + site +
                    ' [Status Code returned: ' + str(r.status_code) + ']')
        return "fail"
Ejemplo n.º 2
0
def torsend2client(seriesname, issue, seriesyear, linkit, site):
    logger.info('matched on ' + seriesname)
    filename = helpers.filesafe(seriesname)
    filename = re.sub(' ', '_', filename)
    filename += "_" + str(issue) + "_" + str(seriesyear)

    if linkit[-7:] != "torrent":  # and site != "KAT":
        filename += ".torrent"

    if mylar.TORRENT_LOCAL and mylar.LOCAL_WATCHDIR is not None:

        filepath = os.path.join(mylar.LOCAL_WATCHDIR, filename)
        logger.fdebug('filename for torrent set to : ' + filepath)
    elif mylar.TORRENT_SEEDBOX and mylar.SEEDBOX_WATCHDIR is not None:
        filepath = os.path.join(mylar.CACHE_DIR, filename)
        logger.fdebug('filename for torrent set to : ' + filepath)
    else:
        logger.error(
            'No Local Watch Directory or Seedbox Watch Directory specified. Set it and try again.'
        )
        return "fail"

    if site == '32P':
        url = 'https://32pag.es/torrents.php'

        if mylar.VERIFY_32P == 1 or mylar.VERIFY_32P == True:
            verify = True
        else:
            verify = False

        logger.fdebug('[32P] Verify SSL set to : ' + str(verify))
        if mylar.MODE_32P == 0:
            if mylar.KEYS_32P is None or mylar.PASSKEY_32P is None:
                logger.warn(
                    '[32P] Unable to retrieve keys from provided RSS Feed. Make sure you have provided a CURRENT RSS Feed from 32P'
                )
                mylar.KEYS_32P = helpers.parse_32pfeed(mylar.FEED_32P)
                if mylar.KEYS_32P is None or mylar.KEYS_32P == '':
                    return "fail"
                else:
                    logger.fdebug(
                        '[32P-AUTHENTICATION] 32P (Legacy) Authentication Successful. Re-establishing keys.'
                    )
                    mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
            else:
                logger.fdebug(
                    '[32P-AUTHENTICATION] 32P (Legacy) Authentication already done. Attempting to use existing keys.'
                )
                mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
        else:
            if any([
                    mylar.USERNAME_32P is None, mylar.USERNAME_32P == '',
                    mylar.PASSWORD_32P is None, mylar.PASSWORD_32P == ''
            ]):
                logger.error(
                    '[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.'
                )
                return "fail"
            elif mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                logger.fdebug(
                    '[32P-AUTHENTICATION] 32P (Auth Mode) Authentication enabled. Keys have not been established yet, attempting to gather.'
                )
                feed32p = auth32p.info32p(reauthenticate=True)
                feedinfo = feed32p.authenticate()
                if feedinfo == "disable":
                    mylar.ENABLE_32P = 0
                    mylar.config_write()
                    return "fail"
                if mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                    logger.error(
                        '[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.'
                    )
                    return "fail"
            else:
                logger.fdebug(
                    '[32P-AUTHENTICATION] 32P (Auth Mode) Authentication already done. Attempting to use existing keys.'
                )

        payload = {
            'action': 'download',
            'torrent_pass': mylar.PASSKEY_32P,
            'authkey': mylar.AUTHKEY_32P,
            'id': linkit
        }

        headers = None  #{'Accept-encoding': 'gzip',
        # 'User-Agent':      str(mylar.USER_AGENT)}

    elif site == 'KAT':
        #stfind = linkit.find('?')
        #if stfind == -1:
        #    kat_referrer = helpers.torrent_create('KAT', linkit)
        #else:
        #    kat_referrer = linkit[:stfind]

        url = helpers.torrent_create('KAT', linkit)

        if url.startswith('https'):
            kat_referrer = 'https://torcache.net/'
        else:
            kat_referrer = 'http://torcache.net/'

        #logger.fdebug('KAT Referer set to :' + kat_referrer)

        headers = {
            'Accept-encoding': 'gzip',
            'User-Agent': str(mylar.USER_AGENT),
            'Referer': kat_referrer
        }

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False

    else:
        headers = {
            'Accept-encoding': 'gzip',
            'User-Agent': str(mylar.USER_AGENT)
        }
        #'Referer': kat_referrer}

        url = linkit  #helpers.torrent_create('TOR', linkit)

        payload = None
        verify = False

    if not verify:
        #32P throws back an insecure warning because it can't validate against the CA. The below suppresses the message just for 32P instead of being displayed.
        #disable SSL warnings - too many 'warning' messages about invalid certificates
        try:
            from lib.requests.packages.urllib3 import disable_warnings
            disable_warnings()
        except ImportError:
            #this is probably not necessary and redudant, but leaving in for the time being.
            from requests.packages.urllib3.exceptions import InsecureRequestWarning
            requests.packages.urllib3.disable_warnings()
            try:
                from urllib3.exceptions import InsecureRequestWarning
                urllib3.disable_warnings()
            except ImportError:
                logger.warn('[EPIC FAILURE] Cannot load the requests module')
                return "fail"

    try:
        r = requests.get(url,
                         params=payload,
                         verify=verify,
                         stream=True,
                         headers=headers)

    except Exception, e:
        logger.warn('Error fetching data from %s: %s' % (site, e))
        if site == '32P':
            if mylar.MODE_32P == 1:
                logger.info(
                    'Attempting to re-authenticate against 32P and poll new keys as required.'
                )
                feed32p = auth32p.info32p(reauthenticate=True)
                feedinfo = feed32p.authenticate()
                if feedinfo == "disable":
                    mylar.ENABLE_32P = 0
                    mylar.config_write()
                    return "fail"
                try:
                    r = requests.get(url,
                                     params=payload,
                                     verify=verify,
                                     stream=True,
                                     headers=headers)
                except Exception, e:
                    logger.warn('Error fetching data from %s: %s' % (site, e))
                    return "fail"
            else:
                logger.warn(
                    '[32P] Unable to authenticate using existing RSS Feed given. Make sure that you have provided a CURRENT feed from 32P'
                )
                return "fail"
Ejemplo n.º 3
0
        try:
            scraper = cfscrape.create_scraper()
            cf_cookievalue, cf_user_agent = scraper.get_tokens(url)
            headers = {'Accept-encoding': 'gzip',
                       'User-Agent':       cf_user_agent}

        except Exception, e:
            return "fail"

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False

    elif site == 'DEM':
        url = helpers.torrent_create('DEM', linkit)

        if url.startswith('https'):
            dem_referrer = 'https://www.dnoid.me/files/download/'
        else:
            dem_referrer = 'http://www.dnoid.me/files/download/'

        headers = {'Accept-encoding': 'gzip',
                   'User-Agent':      str(mylar.USER_AGENT),
                   'Referer':         dem_referrer}

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False
Ejemplo n.º 4
0
def torsend2client(seriesname, issue, seriesyear, linkit, site):
    logger.info('matched on ' + seriesname)
    filename = helpers.filesafe(seriesname)
    filename = re.sub(' ', '_', filename)
    filename += "_" + str(issue) + "_" + str(seriesyear)

    if linkit[-7:] != "torrent":
        filename += ".torrent"
    if any([mylar.USE_UTORRENT, mylar.USE_RTORRENT, mylar.USE_TRANSMISSION,mylar.USE_DELUGE]):
        filepath = os.path.join(mylar.CACHE_DIR, filename)
        logger.fdebug('filename for torrent set to : ' + filepath)
        
    elif mylar.USE_WATCHDIR:
        if mylar.TORRENT_LOCAL and mylar.LOCAL_WATCHDIR is not None:
            filepath = os.path.join(mylar.LOCAL_WATCHDIR, filename)
            logger.fdebug('filename for torrent set to : ' + filepath)
        elif mylar.TORRENT_SEEDBOX and mylar.SEEDBOX_WATCHDIR is not None:
            filepath = os.path.join(mylar.CACHE_DIR, filename)
            logger.fdebug('filename for torrent set to : ' + filepath)
        else:
            logger.error('No Local Watch Directory or Seedbox Watch Directory specified. Set it and try again.')
            return "fail"

    cf_cookievalue = None
    if site == '32P':
        url = 'https://32pag.es/torrents.php'

        if mylar.VERIFY_32P == 1 or mylar.VERIFY_32P == True:
            verify = True
        else:
            verify = False

        logger.fdebug('[32P] Verify SSL set to : ' + str(verify))
        if mylar.MODE_32P == 0:
            if mylar.KEYS_32P is None or mylar.PASSKEY_32P is None:
                logger.warn('[32P] Unable to retrieve keys from provided RSS Feed. Make sure you have provided a CURRENT RSS Feed from 32P')
                mylar.KEYS_32P = helpers.parse_32pfeed(mylar.FEED_32P)
                if mylar.KEYS_32P is None or mylar.KEYS_32P == '':
                    return "fail"
                else:
                    logger.fdebug('[32P-AUTHENTICATION] 32P (Legacy) Authentication Successful. Re-establishing keys.')
                    mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
            else:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Legacy) Authentication already done. Attempting to use existing keys.')
                mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
        else:
            if any([mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None, mylar.PASSWORD_32P == '']):
                logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
                return "fail"
            elif mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication enabled. Keys have not been established yet, attempting to gather.')
                feed32p = auth32p.info32p(reauthenticate=True)
                feedinfo = feed32p.authenticate()
                if feedinfo == "disable":
                    mylar.ENABLE_32P = 0
                    mylar.config_write()
                    return "fail"
                if mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                    logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
                    return "fail"
            else:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication already done. Attempting to use existing keys.')

        payload = {'action':       'download',
                   'torrent_pass': mylar.PASSKEY_32P,
                   'authkey':      mylar.AUTHKEY_32P,
                   'id':           linkit}

        headers = None #{'Accept-encoding': 'gzip',
                       # 'User-Agent':      str(mylar.USER_AGENT)}

    elif site == 'TPSE':
        url = helpers.torrent_create('TPSE', linkit)

        if url.startswith('https'):
            tpse_referrer = 'https://torrentproject.se/'
        else:
            tpse_referrer = 'http://torrentproject.se/'

        try:
            scraper = cfscrape.create_scraper()
            cf_cookievalue, cf_user_agent = scraper.get_tokens(url)
            headers = {'Accept-encoding': 'gzip',
                       'User-Agent':       cf_user_agent}

        except Exception, e:
            return "fail"

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False
Ejemplo n.º 5
0
def torsend2client(seriesname, issue, seriesyear, linkit, site):
    logger.info('matched on ' + seriesname)
    filename = helpers.filesafe(seriesname)
    filename = re.sub(' ', '_', filename)
    filename += "_" + str(issue) + "_" + str(seriesyear)

    if linkit[-7:] != "torrent": # and site != "KAT":
        filename += ".torrent"

    if mylar.TORRENT_LOCAL and mylar.LOCAL_WATCHDIR is not None:

        filepath = os.path.join(mylar.LOCAL_WATCHDIR, filename)
        logger.fdebug('filename for torrent set to : ' + filepath)
    elif mylar.TORRENT_SEEDBOX and mylar.SEEDBOX_WATCHDIR is not None:
        filepath = os.path.join(mylar.CACHE_DIR, filename)
        logger.fdebug('filename for torrent set to : ' + filepath)
    else:
        logger.error('No Local Watch Directory or Seedbox Watch Directory specified. Set it and try again.')
        return "fail"

    if site == '32P':
        url = 'https://32pag.es/torrents.php'

        if mylar.VERIFY_32P == 1 or mylar.VERIFY_32P == True:
            verify = True
        else:
            verify = False

        logger.fdebug('[32P] Verify SSL set to : ' + str(verify))
        if mylar.MODE_32P == 0:
            if mylar.KEYS_32P is None or mylar.PASSKEY_32P is None:
                logger.warn('[32P] Unable to retrieve keys from provided RSS Feed. Make sure you have provided a CURRENT RSS Feed from 32P')
                mylar.KEYS_32P = helpers.parse_32pfeed(mylar.FEED_32P)
                if mylar.KEYS_32P is None or mylar.KEYS_32P == '':
                    return "fail"
                else:
                    logger.fdebug('[32P-AUTHENTICATION] 32P (Legacy) Authentication Successful. Re-establishing keys.')
                    mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
            else:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Legacy) Authentication already done. Attempting to use existing keys.')
                mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
        else:
            if any([mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None, mylar.PASSWORD_32P == '']):
                logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
                return "fail"
            elif mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication enabled. Keys have not been established yet, attempting to gather.')
                feed32p = auth32p.info32p(reauthenticate=True)
                feedinfo = feed32p.authenticate()
                if feedinfo == "disable":
                    mylar.ENABLE_32P = 0
                    mylar.config_write()
                    return "fail"
                if mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                    logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
                    return "fail"
            else:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication already done. Attempting to use existing keys.')

        payload = {'action':       'download',
                   'torrent_pass': mylar.PASSKEY_32P,
                   'authkey':      mylar.AUTHKEY_32P,
                   'id':           linkit}

        headers = None #{'Accept-encoding': 'gzip',
                       # 'User-Agent':      str(mylar.USER_AGENT)}

    elif site == 'KAT':
        #stfind = linkit.find('?')
        #if stfind == -1:
        #    kat_referrer = helpers.torrent_create('KAT', linkit)
        #else:
        #    kat_referrer = linkit[:stfind]

        url = helpers.torrent_create('KAT', linkit)

        if url.startswith('https'):
            kat_referrer = 'https://torcache.net/'
        else:
            kat_referrer = 'http://torcache.net/'

        #logger.fdebug('KAT Referer set to :' + kat_referrer)

        headers = {'Accept-encoding': 'gzip',
                   'User-Agent':      str(mylar.USER_AGENT),
                   'Referer':         kat_referrer}

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False

    else:
        headers = {'Accept-encoding': 'gzip',
                   'User-Agent':      str(mylar.USER_AGENT)}
                   #'Referer': kat_referrer}

        url = linkit #helpers.torrent_create('TOR', linkit)

        payload = None
        verify = False

    if not verify:
        #32P throws back an insecure warning because it can't validate against the CA. The below suppresses the message just for 32P instead of being displayed.
        #disable SSL warnings - too many 'warning' messages about invalid certificates
        try:
            from lib.requests.packages.urllib3 import disable_warnings
            disable_warnings()
        except ImportError:
            #this is probably not necessary and redudant, but leaving in for the time being.
            from requests.packages.urllib3.exceptions import InsecureRequestWarning
            requests.packages.urllib3.disable_warnings()
            try:
                from urllib3.exceptions import InsecureRequestWarning
                urllib3.disable_warnings()
            except ImportError:
                logger.warn('[EPIC FAILURE] Cannot load the requests module')
                return "fail"

    try:
        r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)

    except Exception, e:
        logger.warn('Error fetching data from %s: %s' % (site, e))
        if site == '32P':
            if mylar.MODE_32P == 1:
                logger.info('Attempting to re-authenticate against 32P and poll new keys as required.')
                feed32p = auth32p.info32p(reauthenticate=True)
                feedinfo = feed32p.authenticate()
                if feedinfo == "disable":
                    mylar.ENABLE_32P = 0
                    mylar.config_write()
                    return "fail"
                try:
                    r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)
                except Exception, e:
                    logger.warn('Error fetching data from %s: %s' % (site, e))
                    return "fail"
            else:
                logger.warn('[32P] Unable to authenticate using existing RSS Feed given. Make sure that you have provided a CURRENT feed from 32P')
                return "fail"
Ejemplo n.º 6
0
                try:
                    r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)
                except Exception, e:
                    logger.warn('Error fetching data from %s: %s' % (site, e))
                    return "fail"
            else:
                logger.warn('[32P] Unable to authenticate using existing RSS Feed given. Make sure that you have provided a CURRENT feed from 32P')
                return "fail"
        else:
            logger.info('blah: ' + str(r.status_code))
            return "fail"

    if site == 'KAT' and any([str(r.status_code) == '403', str(r.status_code) == '404']):
        logger.warn('Unable to download from KAT [' + str(r.status_code) + ']') 
        #retry with the alternate torrent link.
        url = helpers.torrent_create('KAT', linkit, True)
        logger.fdebug('Trying alternate url: ' + str(url))
        try:
            r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)

        except Exception, e:
            return "fail"

    if str(r.status_code) != '200':
        logger.warn('Unable to download torrent from ' + site + ' [Status Code returned: ' + str(r.status_code) + ']')
        return "fail"

    if site == 'KAT':
        if r.headers.get('Content-Encoding') == 'gzip':
            buf = StringIO(r.content)
            f = gzip.GzipFile(fileobj=buf)
Ejemplo n.º 7
0
def torsend2client(seriesname, issue, seriesyear, linkit, site):
    logger.info('matched on ' + seriesname)
    filename = helpers.filesafe(seriesname)
    filename = re.sub(' ', '_', filename)
    filename += "_" + str(issue) + "_" + str(seriesyear)

    if linkit[-7:] != "torrent":
        filename += ".torrent"
    if any([mylar.USE_UTORRENT, mylar.USE_RTORRENT, mylar.USE_TRANSMISSION, mylar.USE_DELUGE, mylar.USE_QBITTORRENT]):
        filepath = os.path.join(mylar.CACHE_DIR, filename)
        logger.fdebug('filename for torrent set to : ' + filepath)
        
    elif mylar.USE_WATCHDIR:
        if mylar.TORRENT_LOCAL and mylar.LOCAL_WATCHDIR is not None:
            filepath = os.path.join(mylar.LOCAL_WATCHDIR, filename)
            logger.fdebug('filename for torrent set to : ' + filepath)
        elif mylar.TORRENT_SEEDBOX and mylar.SEEDBOX_WATCHDIR is not None:
            filepath = os.path.join(mylar.CACHE_DIR, filename)
            logger.fdebug('filename for torrent set to : ' + filepath)
        else:
            logger.error('No Local Watch Directory or Seedbox Watch Directory specified. Set it and try again.')
            return "fail"

    cf_cookievalue = None
    if site == '32P':
        url = 'https://32pag.es/torrents.php'

        if mylar.VERIFY_32P == 1 or mylar.VERIFY_32P == True:
            verify = True
        else:
            verify = False

        logger.fdebug('[32P] Verify SSL set to : ' + str(verify))
        if mylar.MODE_32P == 0:
            if mylar.KEYS_32P is None or mylar.PASSKEY_32P is None:
                logger.warn('[32P] Unable to retrieve keys from provided RSS Feed. Make sure you have provided a CURRENT RSS Feed from 32P')
                mylar.KEYS_32P = helpers.parse_32pfeed(mylar.FEED_32P)
                if mylar.KEYS_32P is None or mylar.KEYS_32P == '':
                    return "fail"
                else:
                    logger.fdebug('[32P-AUTHENTICATION] 32P (Legacy) Authentication Successful. Re-establishing keys.')
                    mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
            else:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Legacy) Authentication already done. Attempting to use existing keys.')
                mylar.AUTHKEY_32P = mylar.KEYS_32P['authkey']
        else:
            if any([mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None, mylar.PASSWORD_32P == '']):
                logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
                return "fail"
            elif mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication enabled. Keys have not been established yet, attempting to gather.')
                feed32p = auth32p.info32p(reauthenticate=True)
                feedinfo = feed32p.authenticate()
                if feedinfo == "disable":
                    mylar.ENABLE_32P = 0
                    mylar.config_write()
                    return "fail"
                if mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
                    logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
                    return "fail"
            else:
                logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication already done. Attempting to use existing keys.')

        payload = {'action':       'download',
                   'torrent_pass': mylar.PASSKEY_32P,
                   'authkey':      mylar.AUTHKEY_32P,
                   'id':           linkit}

        headers = None #{'Accept-encoding': 'gzip',
                       # 'User-Agent':      str(mylar.USER_AGENT)}

    elif site == 'TPSE':
        url = helpers.torrent_create('TPSE', linkit)

        if url.startswith('https'):
            tpse_referrer = 'https://torrentproject.se/'
        else:
            tpse_referrer = 'http://torrentproject.se/'

        try:
            scraper = cfscrape.create_scraper()
            cf_cookievalue, cf_user_agent = scraper.get_tokens(url)
            headers = {'Accept-encoding': 'gzip',
                       'User-Agent':       cf_user_agent}

        except Exception, e:
            return "fail"

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False
Ejemplo n.º 8
0
        try:
            scraper = cfscrape.create_scraper()
            cf_cookievalue, cf_user_agent = scraper.get_tokens(url)
            headers = {'Accept-encoding': 'gzip',
                       'User-Agent':       cf_user_agent}

        except Exception, e:
            return "fail"

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False

    elif site == 'DEM':
        url = helpers.torrent_create('DEM', linkit)

        if url.startswith('https'):
            dem_referrer = 'https://www.dnoid.me/files/download/'
        else:
            dem_referrer = 'http://www.dnoid.me/files/download/'

        headers = {'Accept-encoding': 'gzip',
                   'User-Agent':      str(mylar.USER_AGENT),
                   'Referer':         dem_referrer}

        logger.fdebug('Grabbing torrent from url:' + str(url))

        payload = None
        verify = False
Ejemplo n.º 9
0
                try:
                    r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)
                except Exception, e:
                    logger.warn("Error fetching data from %s: %s" % (site, e))
                    return "fail"
            else:
                logger.warn(
                    "[32P] Unable to authenticate using existing RSS Feed given. Make sure that you have provided a CURRENT feed from 32P"
                )
                return "fail"
        else:
            return "fail"

    if str(r.status_code) == "403":
        # retry with the alternate torrent link.
        url = helpers.torrent_create("KAT", linkit, True)
        try:
            r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)

        except Exception, e:
            return "fail"

    if str(r.status_code) != "200":
        logger.warn("Unable to download torrent from " + site + " [Status Code returned: " + str(r.status_code) + "]")
        return "fail"

    if site == "KAT":
        if r.headers.get("Content-Encoding") == "gzip":
            buf = StringIO(r.content)
            f = gzip.GzipFile(fileobj=buf)