Ejemplo n.º 1
0
    def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8181, http_password=None, launch_browser=0, download_scan_interval=None, nzb_search_interval=None, libraryscan_interval=None,
        sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, sab_priority=0, log_dir=None, blackhole=0, blackhole_dir=None,
        usenet_retention=None, nzbsu=0, nzbsu_apikey=None, dognzb=0, dognzb_apikey=None,
        raw=0, raw_provider=None, raw_username=None, raw_password=None, raw_groups=None, experimental=0, 
        preferred_quality=0, move_files=0, rename_files=0, folder_format=None, file_format=None,
        destination_dir=None, replace_spaces=0, replace_char=None, autowant_all=0, autowant_upcoming=0, zero_level=0, zero_level_n=None, interface=None):
        mylar.HTTP_HOST = http_host
        mylar.HTTP_PORT = http_port
        mylar.HTTP_USERNAME = http_username
        mylar.HTTP_PASSWORD = http_password
        mylar.LAUNCH_BROWSER = launch_browser
        mylar.DOWNLOAD_SCAN_INTERVAL = download_scan_interval
        mylar.SEARCH_INTERVAL = nzb_search_interval
        mylar.LIBRARYSCAN_INTERVAL = libraryscan_interval
        mylar.SAB_HOST = sab_host
        mylar.SAB_USERNAME = sab_username
        mylar.SAB_PASSWORD = sab_password      
        mylar.SAB_APIKEY = sab_apikey
        mylar.SAB_CATEGORY = sab_category
        mylar.SAB_PRIORITY = sab_priority
        mylar.BLACKHOLE = blackhole
        mylar.BLACKHOLE_DIR = blackhole_dir
        mylar.USENET_RETENTION = usenet_retention
        mylar.NZBSU = nzbsu
        mylar.NZBSU_APIKEY = nzbsu_apikey
        mylar.DOGNZB = dognzb
        mylar.DOGNZB_APIKEY = dognzb_apikey
        mylar.RAW = raw
        mylar.RAW_PROVIDER = raw_provider
        mylar.RAW_USERNAME = raw_username
        mylar.RAW_PASSWORD = raw_password
        mylar.RAW_GROUPS = raw_groups
        mylar.EXPERIMENTAL = experimental
        mylar.PREFERRED_QUALITY = int(preferred_quality)
        mylar.MOVE_FILES = move_files
        mylar.RENAME_FILES = rename_files
        mylar.REPLACE_SPACES = replace_spaces
        mylar.REPLACE_CHAR = replace_char
        mylar.ZERO_LEVEL = zero_level
        mylar.ZERO_LEVEL_N = zero_level_n
        mylar.FOLDER_FORMAT = folder_format
        mylar.FILE_FORMAT = file_format
        mylar.DESTINATION_DIR = destination_dir
        mylar.AUTOWANT_ALL = autowant_all
        mylar.AUTOWANT_UPCOMING = autowant_upcoming
        mylar.INTERFACE = interface
        mylar.LOG_DIR = log_dir
        mylar.config_write()

        raise cherrypy.HTTPRedirect("config")
Ejemplo n.º 2
0
def tehMain(forcerss=None):
    logger.info('RSS Feed Check was last run at : ' + str(mylar.RSS_LASTRUN))
    firstrun = "no"
    #check the last run of rss to make sure it's not hammering.
    if mylar.RSS_LASTRUN is None or mylar.RSS_LASTRUN == '' or mylar.RSS_LASTRUN == '0' or forcerss == True:
        logger.info('RSS Feed Check First Ever Run.')
        firstrun = "yes"
        mins = 0
    else:
        c_obj_date = datetime.datetime.strptime(mylar.RSS_LASTRUN,
                                                "%Y-%m-%d %H:%M:%S")
        n_date = datetime.datetime.now()
        absdiff = abs(n_date - c_obj_date)
        mins = (absdiff.days * 24 * 60 * 60 +
                absdiff.seconds) / 60.0  #3600 is for hours.

    if firstrun == "no" and mins < int(mylar.RSS_CHECKINTERVAL):
        logger.fdebug(
            'RSS Check has taken place less than the threshold - not initiating at this time.'
        )
        return

    mylar.RSS_LASTRUN = helpers.now()
    logger.fdebug('Updating RSS Run time to : ' + str(mylar.RSS_LASTRUN))
    mylar.config_write()

    #function for looping through nzbs/torrent feeds
    if mylar.ENABLE_TORRENTS:
        logger.fdebug('[RSS] Initiating Torrent RSS Check.')
        if mylar.ENABLE_KAT:
            logger.fdebug('[RSS] Initiating Torrent RSS Feed Check on KAT.')
            torrents(pickfeed='3')
        if mylar.ENABLE_CBT:
            logger.fdebug('[RSS] Initiating Torrent RSS Feed Check on CBT.')
            torrents(pickfeed='1')
            torrents(pickfeed='4')
    logger.fdebug('[RSS] Initiating RSS Feed Check for NZB Providers.')
    nzbs()
    logger.fdebug('[RSS] RSS Feed Check/Update Complete')
    logger.fdebug('[RSS] Watchlist Check for new Releases')
    #if mylar.ENABLE_TORRENTS:
    #    if mylar.ENABLE_KAT:
    #        search.searchforissue(rsscheck='yes')
    #    if mylar.ENABLE_CBT:
    mylar.search.searchforissue(rsscheck='yes')
    #nzbcheck here
    #nzbs(rsscheck='yes')
    logger.fdebug('[RSS] Watchlist Check complete.')
    return
Ejemplo n.º 3
0
def tehMain():
    logger.info('RSS Feed Check was last run at : ' + str(mylar.RSS_LASTRUN))
    firstrun = "no"
    #check the last run of rss to make sure it's not hammering.
    if mylar.RSS_LASTRUN is None or mylar.RSS_LASTRUN == '' or mylar.RSS_LASTRUN == '0':
        logger.info('RSS Feed Check First Ever Run.')
        firstrun = "yes"
        mins = 0
    else:
        c_obj_date = datetime.datetime.strptime(mylar.RSS_LASTRUN, "%Y-%m-%d %H:%M:%S")
        n_date = datetime.datetime.now()
        absdiff = abs(n_date - c_obj_date)
        mins = (absdiff.days * 24 * 60 * 60 + absdiff.seconds) / 60.0  #3600 is for hours.

    if firstrun == "no" and mins < int(mylar.RSS_CHECKINTERVAL):
        logger.fdebug('RSS Check has taken place less than the threshold - not initiating at this time.')
        return

    mylar.RSS_LASTRUN = helpers.now()
    logger.fdebug('Updating RSS Run time to : ' + str(mylar.RSS_LASTRUN))
    mylar.config_write()

    #function for looping through nzbs/torrent feeds
    if mylar.ENABLE_TORRENTS:
        logger.fdebug("[RSS] Initiating Torrent RSS Check.")
        if mylar.ENABLE_KAT:
            logger.fdebug('[RSS] Initiating Torrent RSS Feed Check on KAT.')
            torrents(pickfeed='3')
        if mylar.ENABLE_CBT:
            logger.fdebug('[RSS] Initiating Torrent RSS Feed Check on CBT.')
            torrents(pickfeed='1')
            torrents(pickfeed='4')
    logger.fdebug('RSS] Initiating RSS Feed Check for NZB Providers.')
    nzbs()    
    logger.fdebug('[RSS] RSS Feed Check/Update Complete')
    logger.fdebug('[RSS] Watchlist Check for new Releases')
    #if mylar.ENABLE_TORRENTS:
    #    if mylar.ENABLE_KAT:
    #        search.searchforissue(rsscheck='yes')
    #    if mylar.ENABLE_CBT:    
    mylar.search.searchforissue(rsscheck='yes')
    #nzbcheck here
    #nzbs(rsscheck='yes')
    logger.fdebug('[RSS] Watchlist Check complete.')
    return
Ejemplo n.º 4
0
 def comicScan(self, path, scan=0, redirect=None, autoadd=0, libraryscan=0, imp_move=0, imp_rename=0):
     mylar.LIBRARYSCAN = libraryscan
     mylar.ADD_COMICS = autoadd
     mylar.COMIC_DIR = path
     mylar.IMP_MOVE = imp_move
     mylar.IMP_RENAME = imp_rename
     mylar.config_write()
     if scan:
         try:
             soma = librarysync.libraryScan()
         except Exception, e:
             logger.error('Unable to complete the scan: %s' % e)
         if soma == "Completed":
             print ("sucessfully completed import.")
         else:
             logger.info(u"Starting mass importing...")
             #this is what it should do...
             #store soma (the list of comic_details from importing) into sql table so import can be whenever
             #display webpage showing results
             #allow user to select comic to add (one at a time)
             #call addComic off of the webpage to initiate the add.
             #return to result page to finish or continue adding.
             #....
             #threading.Thread(target=self.searchit).start()
             #threadthis = threadit.ThreadUrl()
             #result = threadthis.main(soma)
             myDB = db.DBConnection()
             sl = 0
             while (sl < len(soma)):
                 soma_sl = soma['comic_info'][sl]
                 print ("cname: " + soma_sl['comicname'])
 
                 controlValue = {"ComicName":    soma_sl['comicname']}
                 newValue = {"ComicYear":        soma_sl['comicyear'],
                             "Status":           "Not Imported",
                             "ImportDate":       helpers.today()}                                
                 myDB.upsert("importresults", newValue, controlValue)
                 sl+=1
                 
             self.importResults()
Ejemplo n.º 5
0
def updateComicLocation():
    import db, logger
    myDB = db.DBConnection()
    if mylar.NEWCOM_DIR is not None:
        logger.info('Performing a one-time mass update to Comic Location')
        #create the root dir if it doesn't exist
        if os.path.isdir(mylar.NEWCOM_DIR):
            logger.info('Directory (' + mylar.NEWCOM_DIR + ') already exists! Continuing...')
        else:
            logger.info('Directory does not exist!')
            try:
                os.makedirs(mylar.NEWCOM_DIR)
                logger.info('Directory successfully created at: ' + mylar.NEWCOM_DIR)
            except OSError:
                logger.error('Could not create comicdir : ' + mylar.NEWCOM_DIR)
                return

        dirlist = myDB.select("SELECT * FROM comics")

        if dirlist is not None:
            for dl in dirlist:
                
                comversion = dl['ComicVersion']                
                if comversion is None:
                    comversion = 'None'
                #if comversion is None, remove it so it doesn't populate with 'None'
                if comversion == 'None':
                    chunk_f_f = re.sub('\$VolumeN','',mylar.FOLDER_FORMAT)
                    chunk_f = re.compile(r'\s+')
                    folderformat = chunk_f.sub(' ', chunk_f_f)
                else:
                    folderformat = mylar.FOLDER_FORMAT

                #remove all 'bad' characters from the Series Name in order to create directories.
                u_comicnm = dl['ComicName']
                u_comicname = u_comicnm.encode('ascii', 'ignore').strip()
                if ':' in u_comicname or '/' in u_comicname or ',' in u_comicname or '?' in u_comicname:
                    comicdir = u_comicname
                if ':' in comicdir:
                    comicdir = comicdir.replace(':','')
                if '/' in comicdir:
                    comicdir = comicdir.replace('/','-')
                if ',' in comicdir:
                    comicdir = comicdir.replace(',','')
                if '?' in comicdir:
                    comicdir = comicdir.replace('?','')
                else: comicdir = u_comicname


                values = {'$Series':        comicdir,
                          '$Publisher':     re.sub('!','',dl['ComicPublisher']),
                          '$Year':          dl['ComicYear'],
                          '$series':        dl['ComicName'].lower(),
                          '$publisher':     re.sub('!','',dl['ComicPublisher']).lower(),
                          '$VolumeY':       'V' + str(dl['ComicYear']),
                          '$VolumeN':       comversion
                          }

                if mylar.FFTONEWCOM_DIR:
                    #if this is enabled (1) it will apply the Folder_Format to all the new dirs
                    if mylar.FOLDER_FORMAT == '':
                        comlocation = re.sub(mylar.DESTINATION_DIR, mylar.NEWCOM_DIR, comicdir)
                    else:
                        first = replace_all(folderformat, values)                    
                        if mylar.REPLACE_SPACES:
                            #mylar.REPLACE_CHAR ...determines what to replace spaces with underscore or dot
                            first = first.replace(' ', mylar.REPLACE_CHAR)
                        comlocation = os.path.join(mylar.NEWCOM_DIR,first)

                else:
                    comlocation = re.sub(mylar.DESTINATION_DIR, mylar.NEWCOM_DIR, comicdir)

                ctrlVal = {"ComicID":    dl['ComicID']}
                newVal = {"ComicLocation": comlocation}
                myDB.upsert("Comics", newVal, ctrlVal)
                logger.fdebug('updated ' + dl['ComicName'] + ' to : ' + comlocation)
        #set the value to 0 here so we don't keep on doing this...
        mylar.LOCMOVE = 0
        mylar.config_write()
    else:
        logger.info('No new ComicLocation path specified - not updating.')
        #raise cherrypy.HTTPRedirect("config")
    return
Ejemplo n.º 6
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.º 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]):
        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
            r = scraper.get(url, params=payload, verify=verify, stream=True, headers=headers)
        #r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)

    except Exception, e:
        logger.warn('Error fetching data from %s (%s): %s' % (site, url, e))
        if site == '32P':
            logger.info('[TOR2CLIENT-32P] Retrying with 32P')
            if mylar.MODE_32P == 1:
                
                logger.info('[TOR2CLIENT-32P] 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"
                
                logger.debug('[TOR2CLIENT-32P] Creating CF Scraper')
                scraper = cfscrape.create_scraper()

                logger.debug('[TOR2CLIENT-32P] payload: %s \n verify %s \n headers %s \n', payload, verify, headers)
                
                try:
                    r = scraper.get(url, params=payload, verify=verify, allow_redirects=True)
                except Exception, e:
                    logger.warn('[TOR2CLIENT-32P] Unable to GET %s (%s): %s' % (site, url, e))
                    return "fail"
            else:
                logger.warn('[TOR2CLIENT-32P] Unable to authenticate using existing RSS Feed given. Make sure that you have provided a CURRENT feed from 32P')
                return "fail"
Ejemplo n.º 9
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.º 10
0
    def run(self):

        with rss_lock:

            logger.info('RSS Feed Check was last run at : ' +
                        str(mylar.RSS_LASTRUN))
            firstrun = "no"
            #check the last run of rss to make sure it's not hammering.
            if mylar.RSS_LASTRUN is None or mylar.RSS_LASTRUN == '' or mylar.RSS_LASTRUN == '0' or self.forcerss == True:
                logger.info('RSS Feed Check First Ever Run.')
                firstrun = "yes"
                mins = 0
            else:
                c_obj_date = datetime.datetime.strptime(
                    mylar.RSS_LASTRUN, "%Y-%m-%d %H:%M:%S")
                n_date = datetime.datetime.now()
                absdiff = abs(n_date - c_obj_date)
                mins = (absdiff.days * 24 * 60 * 60 +
                        absdiff.seconds) / 60.0  #3600 is for hours.

            if firstrun == "no" and mins < int(mylar.RSS_CHECKINTERVAL):
                logger.fdebug(
                    'RSS Check has taken place less than the threshold - not initiating at this time.'
                )
                return

            mylar.RSS_LASTRUN = helpers.now()
            logger.fdebug('Updating RSS Run time to : ' +
                          str(mylar.RSS_LASTRUN))
            mylar.config_write()

            #function for looping through nzbs/torrent feeds
            if mylar.ENABLE_TORRENT_SEARCH:
                logger.info('[RSS] Initiating Torrent RSS Check.')
                if mylar.ENABLE_KAT:
                    logger.info(
                        '[RSS] Initiating Torrent RSS Feed Check on KAT.')
                    rsscheck.torrents(pickfeed='3')
                    rsscheck.torrents(pickfeed='6')
                if mylar.ENABLE_32P:
                    logger.info(
                        '[RSS] Initiating Torrent RSS Feed Check on 32P.')
                    if mylar.MODE_32P == 0:
                        logger.fdebug(
                            '[RSS] 32P mode set to Legacy mode. Monitoring New Releases feed only.'
                        )
                        if any([
                                mylar.PASSKEY_32P is None,
                                mylar.PASSKEY_32P == '',
                                mylar.RSSFEED_32P is None,
                                mylar.RSSFEED_32P == ''
                        ]):
                            logger.error(
                                '[RSS] Unable to validate information from provided RSS Feed. Verify that the feed provided is a current one.'
                            )
                        else:
                            rsscheck.torrents(pickfeed='1',
                                              feedinfo=mylar.KEYS_32P)
                    else:
                        logger.fdebug(
                            '[RSS] 32P mode set to Auth mode. Monitoring all personal notification feeds & New Releases feed'
                        )
                        if any([
                                mylar.USERNAME_32P is None,
                                mylar.USERNAME_32P == '',
                                mylar.PASSWORD_32P is None
                        ]):
                            logger.error(
                                '[RSS] Unable to sign-on to 32P to validate settings. Please enter/check your username password in the configuration.'
                            )
                        else:
                            if mylar.KEYS_32P is None:
                                feed32p = auth32p.info32p()
                                feedinfo = feed32p.authenticate()
                            else:
                                feedinfo = mylar.FEEDINFO_32P

                            if feedinfo is None or len(feedinfo) == 0:
                                logger.error(
                                    '[RSS] Unable to retrieve any information from 32P for RSS Feeds. Skipping for now.'
                                )
                            else:
                                rsscheck.torrents(pickfeed='1',
                                                  feedinfo=feedinfo[0])
                                x = 0
                                #assign personal feeds for 32p > +8
                                for fi in feedinfo:
                                    x += 1
                                    pfeed_32p = str(7 + x)
                                    rsscheck.torrents(pickfeed=pfeed_32p,
                                                      feedinfo=fi)

            logger.info('[RSS] Initiating RSS Feed Check for NZB Providers.')
            rsscheck.nzbs(forcerss=self.forcerss)
            logger.info('[RSS] RSS Feed Check/Update Complete')
            logger.info('[RSS] Watchlist Check for new Releases')
            mylar.search.searchforissue(rsscheck='yes')
            logger.info('[RSS] Watchlist Check complete.')
            if self.forcerss:
                logger.info('[RSS] Successfully ran a forced RSS Check.')
            return
Ejemplo n.º 11
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.º 12
0
            r = scraper.get(url, params=payload, verify=verify, stream=True, headers=headers)
        #r = requests.get(url, params=payload, verify=verify, stream=True, headers=headers)

    except Exception, e:
        logger.warn('Error fetching data from %s (%s): %s' % (site, url, e))
        if site == '32P':
            logger.info('[TOR2CLIENT-32P] Retrying with 32P')
            if mylar.MODE_32P == 1:
                
                logger.info('[TOR2CLIENT-32P] 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"
                
                logger.debug('[TOR2CLIENT-32P] Creating CF Scraper')
                scraper = cfscrape.create_scraper()

                logger.debug('[TOR2CLIENT-32P] payload: %s \n verify %s \n headers %s \n', payload, verify, headers)
                
                try:
                    r = scraper.get(url, params=payload, verify=verify, allow_redirects=True)
                except Exception, e:
                    logger.warn('[TOR2CLIENT-32P] Unable to GET %s (%s): %s' % (site, url, e))
                    return "fail"
            else:
                logger.warn('[TOR2CLIENT-32P] Unable to authenticate using existing RSS Feed given. Make sure that you have provided a CURRENT feed from 32P')
                return "fail"
Ejemplo n.º 13
0
    def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8090, http_password=None, launch_browser=0, logverbose=0, download_scan_interval=None, nzb_search_interval=None, libraryscan_interval=None,
        sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, sab_priority=None, log_dir=None, blackhole=0, blackhole_dir=None,
        usenet_retention=None, nzbsu=0, nzbsu_apikey=None, dognzb=0, dognzb_apikey=None, nzbx=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0,
        raw=0, raw_provider=None, raw_username=None, raw_password=None, raw_groups=None, experimental=0, 
        preferred_quality=0, move_files=0, rename_files=0, folder_format=None, file_format=None, enable_extra_scripts=0, extra_scripts=None, enable_pre_scripts=0, pre_scripts=None,
        destination_dir=None, replace_spaces=0, replace_char=None, use_minsize=0, minsize=None, use_maxsize=0, maxsize=None, autowant_all=0, autowant_upcoming=0, comic_cover_local=0, zero_level=0, zero_level_n=None, interface=None, **kwargs):
        mylar.HTTP_HOST = http_host
        mylar.HTTP_PORT = http_port
        mylar.HTTP_USERNAME = http_username
        mylar.HTTP_PASSWORD = http_password
        mylar.LAUNCH_BROWSER = launch_browser
        mylar.LOGVERBOSE = logverbose
        mylar.DOWNLOAD_SCAN_INTERVAL = download_scan_interval
        mylar.SEARCH_INTERVAL = nzb_search_interval
        mylar.LIBRARYSCAN_INTERVAL = libraryscan_interval
        mylar.SAB_HOST = sab_host
        mylar.SAB_USERNAME = sab_username
        mylar.SAB_PASSWORD = sab_password      
        mylar.SAB_APIKEY = sab_apikey
        mylar.SAB_CATEGORY = sab_category
        mylar.SAB_PRIORITY = sab_priority
        mylar.BLACKHOLE = blackhole
        mylar.BLACKHOLE_DIR = blackhole_dir
        mylar.USENET_RETENTION = usenet_retention
        mylar.NZBSU = nzbsu
        mylar.NZBSU_APIKEY = nzbsu_apikey
        mylar.DOGNZB = dognzb
        mylar.DOGNZB_APIKEY = dognzb_apikey
        mylar.NZBX = nzbx
        mylar.RAW = raw
        mylar.RAW_PROVIDER = raw_provider
        mylar.RAW_USERNAME = raw_username
        mylar.RAW_PASSWORD = raw_password
        mylar.RAW_GROUPS = raw_groups
        mylar.EXPERIMENTAL = experimental
        mylar.NEWZNAB = newznab
        mylar.NEWZNAB_HOST = newznab_host
        mylar.NEWZNAB_APIKEY = newznab_apikey
        mylar.NEWZNAB_ENABLED = newznab_enabled
        mylar.PREFERRED_QUALITY = int(preferred_quality)
        mylar.MOVE_FILES = move_files
        mylar.RENAME_FILES = rename_files
        mylar.REPLACE_SPACES = replace_spaces
        mylar.REPLACE_CHAR = replace_char
        mylar.ZERO_LEVEL = zero_level
        mylar.ZERO_LEVEL_N = zero_level_n
        mylar.USE_MINSIZE = use_minsize
        mylar.MINSIZE = minsize
        mylar.USE_MAXSIZE = use_maxsize
        mylar.MAXSIZE = maxsize
        mylar.FOLDER_FORMAT = folder_format
        mylar.FILE_FORMAT = file_format
        mylar.DESTINATION_DIR = destination_dir
        mylar.AUTOWANT_ALL = autowant_all
        mylar.AUTOWANT_UPCOMING = autowant_upcoming
        mylar.COMIC_COVER_LOCAL = comic_cover_local
        mylar.INTERFACE = interface
        mylar.ENABLE_EXTRA_SCRIPTS = enable_extra_scripts
        mylar.EXTRA_SCRIPTS = extra_scripts
        mylar.ENABLE_PRE_SCRIPTS = enable_pre_scripts
        mylar.PRE_SCRIPTS = pre_scripts
        mylar.LOG_DIR = log_dir

        # Handle the variable config options. Note - keys with False values aren't getting passed

        mylar.EXTRA_NEWZNABS = []

        for kwarg in kwargs:
            if kwarg.startswith('newznab_host'):
                newznab_number = kwarg[12:]
                newznab_host = kwargs['newznab_host' + newznab_number]
                newznab_api = kwargs['newznab_api' + newznab_number]
                try:
                    newznab_enabled = int(kwargs['newznab_enabled' + newznab_number])
                except KeyError:
                    newznab_enabled = 0

                mylar.EXTRA_NEWZNABS.append((newznab_host, newznab_api, newznab_enabled))

        # Sanity checking
        if mylar.SEARCH_INTERVAL < 360:
            logger.info("Search interval too low. Resetting to 6 hour minimum")
            mylar.SEARCH_INTERVAL = 360

        # Write the config
        mylar.config_write()

        raise cherrypy.HTTPRedirect("config")
Ejemplo n.º 14
0
    def run(self):

        with rss_lock:

            logger.info('RSS Feed Check was last run at : ' + str(mylar.RSS_LASTRUN))
            firstrun = "no"
            #check the last run of rss to make sure it's not hammering.
            if mylar.RSS_LASTRUN is None or mylar.RSS_LASTRUN == '' or mylar.RSS_LASTRUN == '0' or self.forcerss == True:
                logger.info('RSS Feed Check First Ever Run.')
                firstrun = "yes"
                mins = 0
            else:
                c_obj_date = datetime.datetime.strptime(mylar.RSS_LASTRUN, "%Y-%m-%d %H:%M:%S")
                n_date = datetime.datetime.now()
                absdiff = abs(n_date - c_obj_date)
                mins = (absdiff.days * 24 * 60 * 60 + absdiff.seconds) / 60.0  #3600 is for hours.

            if firstrun == "no" and mins < int(mylar.RSS_CHECKINTERVAL):
                logger.fdebug('RSS Check has taken place less than the threshold - not initiating at this time.')
                return

            mylar.RSS_LASTRUN = helpers.now()
            logger.fdebug('Updating RSS Run time to : ' + str(mylar.RSS_LASTRUN))
            mylar.config_write()

            #function for looping through nzbs/torrent feeds
            if mylar.ENABLE_TORRENT_SEARCH:
                logger.info('[RSS] Initiating Torrent RSS Check.')
                if mylar.ENABLE_KAT:
                    logger.info('[RSS] Initiating Torrent RSS Feed Check on KAT.')
                    rsscheck.torrents(pickfeed='3')
                    rsscheck.torrents(pickfeed='6')
                if mylar.ENABLE_32P:
                    logger.info('[RSS] Initiating Torrent RSS Feed Check on 32P.')
                    if mylar.MODE_32P == 0:
                        logger.fdebug('[RSS] 32P mode set to Legacy mode. Monitoring New Releases feed only.')
                        if any([mylar.PASSKEY_32P is None, mylar.PASSKEY_32P == '', mylar.RSSFEED_32P is None, mylar.RSSFEED_32P == '']):
                            logger.error('[RSS] Unable to validate information from provided RSS Feed. Verify that the feed provided is a current one.')
                        else:
                            rsscheck.torrents(pickfeed='1', feedinfo=mylar.KEYS_32P)
                    else:
                        logger.fdebug('[RSS] 32P mode set to Auth mode. Monitoring all personal notification feeds & New Releases feed')
                        if any([mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None]):
                            logger.error('[RSS] Unable to sign-on to 32P to validate settings. Please enter/check your username password in the configuration.')
                        else:
                            if mylar.KEYS_32P is None:
                                feed32p = auth32p.info32p()
                                feedinfo = feed32p.authenticate()
                                if feedinfo == "disable":
                                    mylar.ENABLE_32P = 0
                                    mylar.config_write()
                            else:
                                feedinfo = mylar.FEEDINFO_32P

                            if feedinfo is None or len(feedinfo) == 0 or feedinfo == "disable":
                                logger.error('[RSS] Unable to retrieve any information from 32P for RSS Feeds. Skipping for now.')
                            else:
                                rsscheck.torrents(pickfeed='1', feedinfo=feedinfo[0])
                                x = 0
                                #assign personal feeds for 32p > +8
                                for fi in feedinfo:
                                    x+=1
                                    pfeed_32p = str(7 + x)
                                    rsscheck.torrents(pickfeed=pfeed_32p, feedinfo=fi)

            logger.info('[RSS] Initiating RSS Feed Check for NZB Providers.')
            rsscheck.nzbs(forcerss=self.forcerss)
            logger.info('[RSS] RSS Feed Check/Update Complete')
            logger.info('[RSS] Watchlist Check for new Releases')
            mylar.search.searchforissue(rsscheck='yes')
            logger.info('[RSS] Watchlist Check complete.')
            if self.forcerss:
                logger.info('[RSS] Successfully ran a forced RSS Check.')
            return
Ejemplo n.º 15
0
    def run(self, forcerss=None):
        logger.info('forcerss is : %s' % forcerss)
        with rss_lock:

            logger.info('[RSS-FEEDS] RSS Feed Check was last run at : ' + str(mylar.SCHED_RSS_LAST))
            firstrun = "no"
            #check the last run of rss to make sure it's not hammering.
            if mylar.SCHED_RSS_LAST is None or mylar.SCHED_RSS_LAST == '' or mylar.SCHED_RSS_LAST == '0' or forcerss == True:
                logger.info('[RSS-FEEDS] RSS Feed Check Initalizing....')
                firstrun = "yes"
                duration_diff = 0
            else:
                tstamp = float(mylar.SCHED_RSS_LAST)
                duration_diff = abs(helpers.utctimestamp() - tstamp)/60
            logger.fdebug('[RSS-FEEDS] Duration diff: %s' % duration_diff)
            if firstrun == "no" and duration_diff < int(mylar.RSS_CHECKINTERVAL):
                logger.fdebug('[RSS-FEEDS] RSS Check has taken place less than the threshold - not initiating at this time.')
                return

            helpers.job_management(write=True, job='RSS Feeds', current_run=helpers.utctimestamp(), status='Running')
            mylar.RSS_STATUS = 'Running'
            logger.fdebug('[RSS-FEEDS] Updated RSS Run time to : ' + str(mylar.SCHED_RSS_LAST))

            #function for looping through nzbs/torrent feeds
            if mylar.ENABLE_TORRENT_SEARCH:
                logger.info('[RSS-FEEDS] Initiating Torrent RSS Check.')
                if mylar.ENABLE_TPSE:
                    logger.info('[RSS-FEEDS] Initiating Torrent RSS Feed Check on TorrentProject.')
                    #rsscheck.torrents(pickfeed='3')   #TP.SE RSS Check (has to be page-parsed)
                    rsscheck.torrents(pickfeed='TPSE')    #TPSE = DEM RSS Check + WWT RSS Check
                if mylar.ENABLE_32P:
                    logger.info('[RSS-FEEDS] Initiating Torrent RSS Feed Check on 32P.')
                    if mylar.MODE_32P == 0:
                        logger.fdebug('[RSS-FEEDS] 32P mode set to Legacy mode. Monitoring New Releases feed only.')
                        if any([mylar.PASSKEY_32P is None, mylar.PASSKEY_32P == '', mylar.RSSFEED_32P is None, mylar.RSSFEED_32P == '']):
                            logger.error('[RSS-FEEDS] Unable to validate information from provided RSS Feed. Verify that the feed provided is a current one.')
                        else:
                            rsscheck.torrents(pickfeed='1', feedinfo=mylar.KEYS_32P)
                    else:
                        logger.fdebug('[RSS-FEEDS] 32P mode set to Auth mode. Monitoring all personal notification feeds & New Releases feed')
                        if any([mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None]):
                            logger.error('[RSS-FEEDS] Unable to sign-on to 32P to validate settings. Please enter/check your username password in the configuration.')
                        else:
                            if mylar.KEYS_32P is None:
                                feed32p = auth32p.info32p()
                                feedinfo = feed32p.authenticate()
                                if feedinfo == "disable":
                                    mylar.ENABLE_32P = 0
                                    mylar.config_write()
                            else:
                                feedinfo = mylar.FEEDINFO_32P

                            if feedinfo is None or len(feedinfo) == 0 or feedinfo == "disable":
                                logger.error('[RSS-FEEDS] Unable to retrieve any information from 32P for RSS Feeds. Skipping for now.')
                            else:
                                rsscheck.torrents(pickfeed='1', feedinfo=feedinfo[0])
                                x = 0
                                #assign personal feeds for 32p > +8
                                for fi in feedinfo:
                                    x+=1
                                    pfeed_32p = str(7 + x)
                                    rsscheck.torrents(pickfeed=pfeed_32p, feedinfo=fi)

            logger.info('[RSS-FEEDS] Initiating RSS Feed Check for NZB Providers.')
            rsscheck.nzbs(forcerss=forcerss)
            logger.info('[RSS-FEEDS] RSS Feed Check/Update Complete')
            logger.info('[RSS-FEEDS] Watchlist Check for new Releases')
            mylar.search.searchforissue(rsscheck='yes')
            logger.info('[RSS-FEEDS] Watchlist Check complete.')
            if forcerss:
                logger.info('[RSS-FEEDS] Successfully ran a forced RSS Check.')
            helpers.job_management(write=True, job='RSS Feeds', last_run_completed=helpers.utctimestamp(), status='Waiting')
            mylar.RSS_STATUS = 'Waiting'
            return True