def __init__(self): import urlparse cfgsets = config_settings.CfgSettings() self.cgen = cfgsets.cgen self.logsdir = SearchModule.resource_path('logs/nzbmegasearch.log') self.scriptsdir = SearchModule.resource_path('get_stats.sh') self.cfg_urlidx = [] self.excludeurls= ['http://ftdworld.net', 'https://nzbx.co'] if(cfgsets.cfg is not None): self.config = cfgsets.cfg for i in xrange(len(self.config)): if(self.config[i]['builtin'] == 0): self.cfg_urlidx.append(i)
def __init__(self): import urlparse cfgsets = config_settings.CfgSettings() self.cgen = cfgsets.cgen self.logsdir = SearchModule.resource_path('logs/nzbmegasearch.log') self.scriptsdir = SearchModule.resource_path('get_stats.sh') self.cfg_urlidx = [] self.excludeurls = ['http://ftdworld.net', 'https://nzbx.co'] if (cfgsets.cfg is not None): self.config = cfgsets.cfg for i in xrange(len(self.config)): if (self.config[i]['builtin'] == 0): self.cfg_urlidx.append(i)
def __init__(self, conf, cgen): self.trendsdir = SearchModule.resource_path('logs/') self.timeout = cgen['default_timeout'] self.movie_trend = [] self.movie_trend_ts = 0 self.show_trend = [] self.show_trend_ts = 0 self.sugg_info = [] self.active_trend = 1 self.trends_refreshrate = cgen['trends_refreshrate'] self.detached_trendpolling = cgen['large_server'] self.best_k = cgen['trends_qty'] self.cgen = cgen self.logic_expr = re.compile("(?:^|\s)([-+])(\w+)") self.predb_info = [] self.tvrage_rqheaders = { 'Connection': 'keep-alive;', 'Cache-Control': 'max-age=0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17', 'Referer': 'http://services.tvrage.com/info.php?page=main', 'Accept-Encoding': 'gzip,deflate,sdch', 'Accept-Language': 'en-US,en;q=0.8', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' } if (int(cgen['general_trend']) == 0): self.active_trend = 0
def __init__(self, conf, cgen): self.trendsdir = SearchModule.resource_path('logs/') self.timeout = cgen['default_timeout'] self.movie_trend = [] self.movie_trend_ts = 0 self.show_trend = [] self.show_trend_ts = 0 self.sugg_info = [] self.active_trend = 1 self.trends_refreshrate = cgen['trends_refreshrate'] self.detached_trendpolling = cgen['large_server'] self.best_k = cgen['trends_qty'] self.cgen = cgen self.logic_expr = re.compile("(?:^|\s)([-+])(\w+)") self.predb_info = [] self.tvrage_rqheaders = { 'Connection': 'keep-alive;' , 'Cache-Control': 'max-age=0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17', 'Referer': 'http://services.tvrage.com/info.php?page=main', 'Accept-Encoding': 'gzip,deflate,sdch', 'Accept-Language': 'en-US,en;q=0.8', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' } if(int(cgen['general_trend']) == 0): self.active_trend = 0
import threading from SuggestionModule import SuggestionResponses import config_settings import SearchModule import logging import logging.handlers import time DEBUGFLAG = True motd = '\n\n~*~ ~*~ NZBMegasearcH detached trend ~*~ ~*~' print motd #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ cfgsets = config_settings.CfgSettings() logsdir = SearchModule.resource_path('logs/') logging.basicConfig(filename=logsdir+'nzbmegasearch_detachedtrend.log',level=logging.INFO,format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') log = logging.getLogger(__name__) handler = logging.handlers.RotatingFileHandler(logsdir+'nzbmegasearch_detachedtrend.log', maxBytes=cfgsets.cgen['log_size'], backupCount=cfgsets.cgen['log_backupcount']) log.addHandler(handler) log.info(motd) cfgsets.cgen['trends'] = 1 cfgsets.cgen['search_suggestions'] = 1 cfgsets.cgen['large_server'] = False sugg = SuggestionResponses(cfgsets.cfg, cfgsets.cgen) #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ def pollsuggestions(): sugg.asktrend_allparallel() sugg.asktrend_saveondisk()
mega_parall = megasearch.DoParallelSearch(cfgsets.cfg, cfgsets.cgen, ds, wrp) apiresp = ApiResponses(cfgsets.cfg, cfgsets.cgen, wrp, ds) getsmartinfo = nzbsanity.GetNZBInfo(cfgsets.cfg, cfgsets.cgen, ds, app) auth = miscdefs.Auth(cfgsets) testserver = miscdefs.ChkServer(cfgsets.cgen) # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ motd = '\n\n~*~ ~*~ NZBMegasearcH ~*~ ~*~' print motd DEBUGFLAG = False LARGESERVER = False logsdir = SearchModule.resource_path('logs/') if (len(os.getenv('OPENSHIFT_DATA_DIR', ''))): logsdir = os.environ.get('OPENSHIFT_DATA_DIR') if (len(sys.argv) > 1): for argv in sys.argv: if (argv == 'help'): print '' print '`debug`: start in debug mode' print '`large`: modality for GUNICORN + NGINX large server' print '`daemon`: start in daemon mode, detached from terminal' print '' exit() if (argv == 'debug'): print '====== DEBUGMODE DEBUGMODE DEBUGMODE DEBUGMODE ======'
cfgsets.cgen['large_server'] = LARGESERVER sugg = SuggestionResponses(cfgsets.cfg, cfgsets.cgen) ds = DeepsearchModule.DeepSearch(cfgsets.cfg_deep, cfgsets.cgen) wrp = Warper (cfgsets.cgen, cfgsets.cfg, ds) mega_parall = megasearch.DoParallelSearch(cfgsets.cfg, cfgsets.cgen, ds, wrp) apiresp = ApiResponses(cfgsets.cfg, cfgsets.cgen, wrp, ds) auth = miscdefs.Auth(cfgsets) #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ motd = '\n\n~*~ ~*~ NZBMegasearcH ~*~ ~*~' print motd DEBUGFLAG = False LARGESERVER = False logsdir = SearchModule.resource_path('logs/') if(len(os.getenv('OPENSHIFT_DATA_DIR', ''))): logsdir = os.environ.get('OPENSHIFT_DATA_DIR') if(len(sys.argv) > 1): for argv in sys.argv: if(argv == 'help'): print '' print '`debug`: start in debug mode' print '`large`: modality for GUNICORN + NGINX large server' print '`daemon`: start in daemon mode, detached from terminal' print '' exit() if(argv == 'debug'): print '====== DEBUGMODE DEBUGMODE DEBUGMODE DEBUGMODE ======'
import threading from SuggestionModule import SuggestionResponses import config_settings import SearchModule import logging import logging.handlers import time DEBUGFLAG = True motd = '\n\n~*~ ~*~ NZBMegasearcH detached trend ~*~ ~*~' print motd #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ cfgsets = config_settings.CfgSettings() logsdir = SearchModule.resource_path('logs/') logging.basicConfig( filename=logsdir + 'nzbmegasearch_detachedtrend.log', level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') log = logging.getLogger(__name__) handler = logging.handlers.RotatingFileHandler( logsdir + 'nzbmegasearch_detachedtrend.log', maxBytes=cfgsets.cgen['log_size'], backupCount=cfgsets.cgen['log_backupcount']) log.addHandler(handler) log.info(motd) cfgsets.cgen['trends'] = 1 cfgsets.cgen['search_suggestions'] = 1 cfgsets.cgen['large_server'] = False sugg = SuggestionResponses(cfgsets.cfg, cfgsets.cgen)
import SearchModule from ApiModule import ApiResponses from SuggestionModule import SuggestionResponses import megasearch import config_settings import miscdefs DEBUGFLAG = False motd = '\n\n~*~ ~*~ NZBMegasearcH ~*~ ~*~' print motd #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ #~ bootstrap datefmt='%Y-%m-%d %H:%M:%S' cfg,cgen = config_settings.read_conf() logsdir = SearchModule.resource_path('logs/') logging.basicConfig(filename=logsdir+'nzbmegasearch.log',level=logging.INFO,format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') log = logging.getLogger(__name__) handler = logging.handlers.RotatingFileHandler(logsdir+'nzbmegasearch.log', maxBytes=cgen['log_size'], backupCount=cgen['log_backupcount']) log.addHandler(handler) log.info(motd) templatedir = SearchModule.resource_path('templates') app = Flask(__name__, template_folder=templatedir) cver = miscdefs.ChkVersion() print '>> version: '+ str(cver.ver_notify['curver']) SearchModule.loadSearchModules() if(DEBUGFLAG): cgen['general_trend'] = 0 print 'MEGA2: DEBUGFLAG MUST BE SET TO FALSE BEFORE DEPLOYMENT' sugg = SuggestionResponses(cfg, cgen) mega_parall = megasearch.DoParallelSearch(cfg)
LARGESERVER = True # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ cver = miscdefs.ChkVersion(DEBUGFLAG) print ">> version: " + str(cver.ver_notify["curver"]) motd = motd + " v." + str(cver.ver_notify["curver"]) + "large_server: " + str(LARGESERVER) + " debug: " + str(DEBUGFLAG) cfgsets = config_settings.CfgSettings() first_time = 0 reload_all() if cfgsets.cfg is None or cfgsets.cfg_deep is None: first_time = 1 ">> It will be configured" logsdir = SearchModule.resource_path("logs/") if len(os.getenv("OPENSHIFT_DATA_DIR", "")): logsdir = os.environ.get("OPENSHIFT_DATA_DIR") certdir = SearchModule.resource_path("certificates/") log = logging.getLogger() handler = logging.handlers.RotatingFileHandler( logsdir + "nzbmegasearch.log", maxBytes=cfgsets.cgen["log_size"], backupCount=cfgsets.cgen["log_backupcount"] ) log.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") handler.setFormatter(formatter) log.addHandler(handler) log.info(motd) templatedir = SearchModule.resource_path("templates") app = Flask(__name__, template_folder=templatedir)