def main(args): global time_of_last_run time_of_last_run = time.time() if sys.argv[1] == "additional": print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {} {} releases. passwordstatus range {} to -1".format(run_threads, "{:,}".format(len(datas)), sys.argv[1], maxtries) + bcolors.ENDC) elif sys.argv[1] == "nfo": print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {} {} releases. nfostatus range {} to -1".format(run_threads, "{:,}".format(len(datas)), sys.argv[1], maxtries) + bcolors.ENDC) else: print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {} {} releases.".format(run_threads, "{:,}".format(len(datas)), sys.argv[1]) + bcolors.ENDC) time.sleep(2) def signal_handler(signal, frame): sys.exit(0) signal.signal(signal.SIGINT, signal_handler) if True: #spawn a pool of place worker threads for i in range(run_threads): p = queue_runner(my_queue) p.setDaemon(False) p.start() #now load some arbitrary jobs into the queue if sys.argv[1] == "additional": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s =+= %s =+= %s =+= %s =+= %s =+= %s =+= %s =+= %s") % (release[0], release[1], release[2], release[3], release[4], release[5], release[6], release[7], release[8])) elif sys.argv[1] == "nfo": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s =+= %s =+= %s") % (release[0], release[1], release[2], release[3])) elif sys.argv[1] == "movie": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s =+= %s") % (release[0], release[1], release[2])) elif sys.argv[1] == "tv": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s") % (release[0], release[1])) my_queue.join() if sys.argv[1] == "nfo": cur = info.connect() cur[0].execute("SELECT id from releases WHERE nfostatus <= -6") final = cur[0].fetchall() if len(datas) > 0: for item in final: run = "DELETE FROM releasenfo WHERE nfo IS NULL AND releaseid = %s" cur[0].execute(run, (item[0])) final = cur[0].fetchall() #close connection to mysql info.disconnect(cur[0], cur[1]) print(bcolors.HEADER + "\nPostProcess {} Threaded Completed at {}".format(sys.argv[1],datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) print(bcolors.HEADER + "Running time: {}\n\n".format(str(datetime.timedelta(seconds=time.time() - start_time))) + bcolors.ENDC)
def main(args): global time_of_last_run time_of_last_run = time.time() print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {}.".format(run_threads, "{:,}".format(len(datas))) + bcolors.ENDC) time.sleep(2) def signal_handler(signal, frame): sys.exit(0) signal.signal(signal.SIGINT, signal_handler) if True: #spawn a pool of place worker threads for i in range(run_threads): p = queue_runner(my_queue) p.setDaemon(False) p.start() #now load some arbitrary jobs into the queue if sys.argv[1] == "additional": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) elif sys.argv[1] == "nfo": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) elif sys.argv[1] == "movie": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) elif sys.argv[1] == "tv": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) my_queue.join() if sys.argv[1] == "nfo": cur = info.connect() cur[0].execute("SELECT id from releases WHERE nfostatus <= -6") final = cur[0].fetchall() if len(datas) > 0: for item in final: run = "DELETE FROM release_nfos WHERE nfo IS NULL AND releaseid = %s" cur[0].execute(run, (item[0])) final = cur[0].fetchall() #close connection to mysql info.disconnect(cur[0], cur[1]) print(bcolors.HEADER + "\nPostProcess {} Threaded Completed at {}".format(sys.argv[1],datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) print(bcolors.HEADER + "Running time: {}\n\n".format(str(datetime.timedelta(seconds=time.time() - start_time))) + bcolors.ENDC)
import sys, os, time import threading try: import queue except ImportError: import Queue as queue import subprocess import string import signal import datetime import lib.info as info from lib.info import bcolors conf = info.readConfig() cur = info.connect() start_time = time.time() pathname = os.path.abspath(os.path.dirname(sys.argv[0])) if len(sys.argv) == 1: print( bcolors.ERROR + "\nAn argument is required\n\n" + "python " + sys.argv[0] + " [md5, nfo, filename, par2, miscsorter, predbft] ...: To process all previously unprocessed releases, using [md5, nfo, filename, par2, miscsorter, predbft].\n" + bcolors.ENDC) sys.exit() if sys.argv[1] != "nfo" and sys.argv[1] != "filename" and sys.argv[ 1] != "md5" and sys.argv[1] != "par2" and sys.argv[ 1] != "miscsorter" and sys.argv[1] != "predbft": print(
from __future__ import print_function from __future__ import unicode_literals import sys, os, time import threading try: import queue except ImportError: import Queue as queue import subprocess import string import signal import datetime import lib.info as info from lib.info import bcolors conf = info.readConfig() cur = info.connect() if len(sys.argv) == 1: print(bcolors.ERROR + "\nWrong set of arguments.\nThe first argument [additional, nfo, movie, clean] determines the postprocessing to do.\nThe optional second argument for [additional, nfo] [groupid, categoryid] allows to process only that group or category.\nThe optional second argument for [movies, tv] [clean] allows processing only properly renamed releases.\n\npython postprocess_threaded.py [additional, nfo] (optional [groupid, categoryid])\npython postprocess_threaded.py [movie, tv] (optional [clean])\n" + bcolors.ENDC) sys.exit() if len(sys.argv) == 3 and sys.argv[2] == "clean": print(bcolors.HEADER + "\nPostProcess {} Clean Threaded Started at {}".format(sys.argv[1],datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) else: print(bcolors.HEADER + "\nPostProcess {} Threaded Started at {}".format(sys.argv[1],datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) if sys.argv[1] == "additional": print(bcolors.HEADER + "Downloaded: b = yEnc article, f= failed ;Processing: z = zip file, r = rar file" + bcolors.ENDC); print(bcolors.HEADER + "Added: s = sample image, j = jpeg image, A = audio sample, a = audio mediainfo, v = video sample" + bcolors.ENDC); print(bcolors.HEADER + "Added: m = video mediainfo, n = nfo, ^ = file details from inside the rar/zip" + bcolors.ENDC); elif sys.argv[1] == "nfo": print(bcolors.HEADER + "* = hidden NFO, + = NFO, - = no NFO, f = download failed." + bcolors.ENDC)