예제 #1
0
    def run(self):
        """ Threaded loading of elements. """
        self._keep_running = True
        if self._testing_cache is not None:
            self._testing_cache = []

        for source in self.sources:
            stringutil.print_color(
                Fore.GREEN, 'Downloading from Source: %s' % source.get_alias())
            for r in source.get_elements():
                if not self._keep_running:
                    return
                r.set_source(source)
                while self._keep_running:
                    try:  # Keep trying to add this element to the queue, with a timeout to catch any stop triggers.
                        self._queue.put(r, timeout=1)
                        break
                    except queue.Full:
                        pass
                # Extra tracking stuff below:
                with self._c_lock:
                    self._total_count += 1
                if self._testing_cache is not None:
                    self._testing_cache.append(r)
        self._keep_running = False
예제 #2
0
def check_legacy(base_dir):
	""" Moves elements from legacy manifest, if one exists, to the new DB. """
	if os.path.exists('./Manifest.json.gz'):
		stringutil.print_color(stringutil.Fore.GREEN, '\n\nCONVERTING LEGACY MANIFEST...')
		from classes.tools import manifest_converter as mc
		data = mc.load('./Manifest.json.gz')
		mc.convert(base_dir, data)
		os.rename('./Manifest.json.gz', './Legacy - Manifest.json.gz')
		print('Finished conversion.\n\n')
예제 #3
0
def prompt_list(prompt, options, allow_none=False):
    """ Prompts for the user to select an option from the list, and returns the index.
	 	If *options* is an array of tuples, they are prompted with [1], and [0] is returned.
	"""
    if len(options) == 0:
        return None
    stringutil.print_color(Fore.CYAN, prompt)
    is_tuple = isinstance(options[0], tuple)
    if not is_tuple:
        options = [(o, o) for o in options]
    if allow_none:
        options.append(('Cancel', None))
    for idx, opt in enumerate(options):
        print("\t%s: %s" % (idx + 1, opt[1]))
    select = number("Choose an option", 1, len(options), round_val=True) - 1
    return options[select][0]
예제 #4
0
 def run(self):
     _start_time = time.time()
     try:
         self.loader = RedditLoader(self.test)
         self.loader.scan(self.sources)  # Starts the scanner thread.
         self.processor = ElementProcessor(self.loader)
         self.processor.run()  # hangs until processor runs out of elements.
         # Reaching this point should indicate that the loader & processor are finished.
     except Exception:
         raise
     finally:
         self.stop()
     self._total_time = str(
         datetime.timedelta(seconds=round(time.time() - _start_time)))
     su.print_color(
         Fore.GREEN,
         'Found %s posts missing files - with %s new files downloaded - and %s files that cannot be found.'
         % (self.processor.total_posts, self.processor.total_urls,
            self.processor.failed_urls))
     print('Finished processing in %s.' % self._total_time)
예제 #5
0
def pause():
    """ Prompts the User to press any button to continue. """
    stringutil.print_color(Fore.GREEN, '[Press Enter to continue]')
    input()
예제 #6
0
def col_input(prompt, color=Fore.LIGHTYELLOW_EX):
    """ Prints a colorized input prompt. """
    stringutil.print_color(color, prompt, end='')
    return input()
예제 #7
0
    sys.exit(1)

from classes.webserver import eelwrapper
import colorama
from colorama import Fore
from classes.static import settings
from classes.static import stringutil
from classes.static import console
from classes.static import manifest
from classes.downloader import RMD

colorama.init(convert=True)
stringutil.print_color(
    Fore.GREEN, """
====================================
    Reddit Media Downloader %s
====================================
    (By ShadowMoose @ Github)
""" % __version__)

if args.version:
    sys.exit(0)

if args.list_settings:  # !cover
    print('All valid overridable settings:')
    for _s in settings.get_all():
        if _s.public:
            print("%s.%s" % (_s.category, _s.name))
            print('\tDescription: %s' % _s.description)
            if not _s.opts:
                print('\tValid value: \n\t\tAny %s' % _s.type)