def main(): slogging.setupLogging() parser = OptionParser(usage = 'usage: %prog [options] file1 [file2...]') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help = 'display debug output') parser.add_option('-i', '--info', dest = 'info', default = 'filename', help = 'the desired information type: filename, hash_mpc or a hash from python\'s ' 'hashlib module, such as hash_md5, hash_sha1, ...; or a list of any of ' 'them, comma-separated') parser.add_option('-t', '--type', dest = 'filetype', default = 'autodetect', help = 'the suggested file type: movie, episode or autodetect') parser.add_option('-d', '--demo', action='store_true', dest='demo', default=False, help = 'run a few builtin tests instead of analyzing a file') options, args = parser.parse_args() if options.verbose: logging.getLogger('guessit').setLevel(logging.DEBUG) if options.demo: run_demo(episodes=True, movies=True) else: if args: for filename in args: detect_filename(filename, filetype = options.filetype, info = options.info.split(',')) else: parser.print_help()
def __init__(self): super(SmewtDaemon, self).__init__() # Note: put log file in data dir instead of log dir so that it is # accessible through the user/ folder static view self.logfile = utils.path(smewt.dirs.user_data_dir, "Smewt.log") setupLogging(filename=self.logfile, with_time=True, with_thread=True) if smewt.config.PERSISTENT_CACHE: self.loadCache() # get a TaskManager for all the import tasks self.taskManager = TaskManager() # get our main graph DB self.loadDB() # get our collections: series and movies for now self.episodeCollection = Collection( name="Series", # import episodes and their subtitles too validFiles=[Episode.isValidEpisode, Subtitle.isValidSubtitle], mediaTagger=EpisodeTagger, dataGraph=self.database, taskManager=self.taskManager, ) self.movieCollection = Collection( name="Movie", # import movies and their subtitles too validFiles=[Movie.isValidMovie, Subtitle.isValidSubtitle], mediaTagger=MovieTagger, dataGraph=self.database, taskManager=self.taskManager, ) if config.REGENERATE_THUMBNAILS: # launch the regeneration of the thumbnails, but only after everything # is setup and we are able to serve requests Timer(3, self.regenerateSpeedDialThumbnails).start() if self.database.config.get("tvuMldonkeyPlugin"): # load up the feed watcher self.feedWatcher = FeedWatcher(self) # FIXME: this should go into a plugin.init() method from smewt.plugins import mldonkey mldonkey.send_command("vm") # do not rescan as it would be too long and we might delete some files that # are on an unaccessible network share or an external HDD self.taskManager.add(FuncTask("Update collections", self.updateCollections))
def main(): slogging.setupLogging() if PY2: import codecs import locale import sys # see http://bugs.python.org/issue2128 if os.name == 'nt': for i, a in enumerate(sys.argv): sys.argv[i] = a.decode(locale.getpreferredencoding()) # see https://github.com/wackou/guessit/issues/43 # and http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file # Wrap sys.stdout into a StreamWriter to allow writing unicode. sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) parser = OptionParser(usage='usage: %prog [options] file1 [file2...]') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='display debug output') parser.add_option('-p', '--properties', dest='properties', action='store_true', default=False, help='Display properties that can be guessed by the filename matcher.') parser.add_option('-i', '--info', dest='info', default='filename', help='the desired information type: filename, hash_mpc or a hash from python\'s ' 'hashlib module, such as hash_md5, hash_sha1, ...; or a list of any of ' 'them, comma-separated') parser.add_option('-t', '--type', dest='filetype', default='autodetect', help='the suggested file type: movie, episode or autodetect') parser.add_option('-a', '--advanced', dest='advanced', action='store_true', default=False, help='display advanced information for filename guesses, as json output') parser.add_option('-d', '--demo', action='store_true', dest='demo', default=False, help='run a few builtin tests instead of analyzing a file') options, args = parser.parse_args() if options.verbose: logging.getLogger('guessit').setLevel(logging.DEBUG) if options.properties: display_properties() if options.demo: run_demo(episodes=True, movies=True, advanced=options.advanced) else: if args: for filename in args: detect_filename(filename, filetype=options.filetype, info=options.info.split(','), advanced=options.advanced) else: parser.print_help()
def main(args=None, setup_logging=True): if setup_logging: from guessit import slogging slogging.setupLogging() if PY2: # pragma: no cover import codecs import locale import sys # see http://bugs.python.org/issue2128 if os.name == 'nt': for i, a in enumerate(sys.argv): sys.argv[i] = a.decode(locale.getpreferredencoding()) # see https://github.com/wackou/guessit/issues/43 # and http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file # Wrap sys.stdout into a StreamWriter to allow writing unicode. sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) if args: options, args = option_parser.parse_args(args) else: # pragma: no cover options, args = option_parser.parse_args() if options.verbose: logging.getLogger().setLevel(logging.DEBUG) help_required = True if options.properties or options.values: display_properties(options) help_required = False elif options.transformers: display_transformers() help_required = False if options.demo: run_demo(episodes=True, movies=True, options=vars(options)) help_required = False elif options.submit_bug: for filename in args: help_required = False submit_bug(filename) else: if args: help_required = False for filename in args: guess_file(filename, info=options.info.split(','), options=vars(options)) if help_required: # pragma: no cover option_parser.print_help()
def main(): slogging.setupLogging() parser = OptionParser(usage='usage: %prog [options] file1 [file2...]') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='display debug output') parser.add_option( '-i', '--info', dest='info', default='filename', help= 'the desired information type: filename, hash_mpc or a hash from python\'s ' 'hashlib module, such as hash_md5, hash_sha1, ...; or a list of any of ' 'them, comma-separated') parser.add_option( '-t', '--type', dest='filetype', default='autodetect', help='the suggested file type: movie, episode or autodetect') parser.add_option( '-d', '--demo', action='store_true', dest='demo', default=False, help='run a few builtin tests instead of analyzing a file') options, args = parser.parse_args() if options.verbose: logging.getLogger('guessit').setLevel(logging.DEBUG) if options.demo: run_demo(episodes=True, movies=True) else: if args: for filename in args: detect_filename(filename, filetype=options.filetype, info=options.info.split(',')) else: parser.print_help()
def main(): slogging.setupLogging() parser = OptionParser(usage="usage: %prog [options] file1 [file2...]") parser.add_option( "-v", "--verbose", action="store_true", dest="verbose", default=False, help="display debug output" ) parser.add_option( "-i", "--info", dest="info", default="filename", help="the desired information type: filename, hash_mpc or a hash from python's " "hashlib module, such as hash_md5, hash_sha1, ...; or a list of any of " "them, comma-separated", ) parser.add_option( "-t", "--type", dest="filetype", default="autodetect", help="the suggested file type: movie, episode or autodetect", ) parser.add_option( "-d", "--demo", action="store_true", dest="demo", default=False, help="run a few builtin tests instead of analyzing a file", ) options, args = parser.parse_args() if options.verbose: logging.getLogger("guessit").setLevel(logging.DEBUG) if options.demo: run_demo(episodes=True, movies=True) else: if args: for filename in args: detect_filename(filename, filetype=options.filetype, info=options.info.split(",")) else: parser.print_help()
def main(): slogging.setupLogging() # see http://bugs.python.org/issue2128 if sys.version_info.major < 3 and os.name == 'nt': for i, a in enumerate(sys.argv): sys.argv[i] = a.decode(locale.getpreferredencoding()) parser = OptionParser(usage = 'usage: %prog [options] file1 [file2...]') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help = 'display debug output') parser.add_option('-i', '--info', dest = 'info', default = 'filename', help = 'the desired information type: filename, hash_mpc or a hash from python\'s ' 'hashlib module, such as hash_md5, hash_sha1, ...; or a list of any of ' 'them, comma-separated') parser.add_option('-t', '--type', dest = 'filetype', default = 'autodetect', help = 'the suggested file type: movie, episode or autodetect') parser.add_option('-a', '--advanced', dest = 'advanced', action='store_true', default = False, help = 'display advanced information for filename guesses, as json output') parser.add_option('-d', '--demo', action='store_true', dest='demo', default=False, help = 'run a few builtin tests instead of analyzing a file') options, args = parser.parse_args() if options.verbose: logging.getLogger('guessit').setLevel(logging.DEBUG) if options.demo: run_demo(episodes=True, movies=True, advanced=options.advanced) else: if args: for filename in args: detect_filename(filename, filetype = options.filetype, info = options.info.split(','), advanced = options.advanced) else: parser.print_help()
# README # # run with: # python -m cProfile -o /tmp/profstats bin/test_import.py # view with # runsnake /tmp/profstats from PyQt4.QtGui import QApplication from smewt.base.smewtdaemon import SmewtDaemon from guessit import slogging import sys import smewt import logging slogging.setupLogging() logging.getLogger().setLevel(logging.INFO) log = logging.getLogger(__name__) app = QApplication(sys.argv) app.setOrganizationName(smewt.ORG_NAME) app.setOrganizationDomain('smewt.com') app.setApplicationName(smewt.APP_NAME) s = SmewtDaemon() print len(list(s.database.nodes())) print 'NUM TASKS IN Q:', s.taskManager.queue.qsize() #s.updateCollections() s.rescanCollections()
#!/usr/bin/env python # -*- coding: utf-8 -*- # # GuessIt - A library for guessing information from filenames # Copyright (c) 2013 Nicolas Wack <*****@*****.**> # # GuessIt is free software; you can redistribute it and/or modify it under # the terms of the Lesser GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # GuessIt is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # Lesser GNU General Public License for more details. # # You should have received a copy of the Lesser GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from __future__ import absolute_import, division, print_function, unicode_literals import logging from guessit.slogging import setupLogging setupLogging() logging.disable(logging.INFO)
def main(args=None, setup_logging=True): if setup_logging: from guessit import slogging slogging.setupLogging() if PY2: # pragma: no cover import codecs import locale import sys # see http://bugs.python.org/issue2128 if os.name == 'nt': for i, a in enumerate(sys.argv): sys.argv[i] = a.decode(locale.getpreferredencoding()) # see https://github.com/wackou/guessit/issues/43 # and http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file # Wrap sys.stdout into a StreamWriter to allow writing unicode. sys.stdout = codecs.getwriter(locale.getpreferredencoding())( sys.stdout) if args: options, args = get_opts().parse_args(args) else: # pragma: no cover options, args = get_opts().parse_args() if options.verbose: logging.getLogger().setLevel(logging.DEBUG) help_required = True if options.properties or options.values: display_properties(options) help_required = False elif options.transformers: display_transformers() help_required = False if options.demo: run_demo(episodes=True, movies=True, options=vars(options)) help_required = False if options.version: print('+-------------------------------------------------------+') print('+ GuessIt ' + __version__ + (28 - len(__version__)) * ' ' + '+') print('+-------------------------------------------------------+') print('| Please report any bug or feature request at |') print('| https://github.com/wackou/guessit/issues. |') print('+-------------------------------------------------------+') help_required = False if options.yaml: try: import yaml, babelfish def default_representer(dumper, data): return dumper.represent_str(str(data)) yaml.SafeDumper.add_representer(babelfish.Language, default_representer) yaml.SafeDumper.add_representer(babelfish.Country, default_representer) except ImportError: # pragma: no cover print('PyYAML not found. Using default output.') filenames = [] if args: filenames.extend(args) if options.input_file: input_file = open(options.input_file, 'r') try: filenames.extend([line.strip() for line in input_file.readlines()]) finally: input_file.close() filenames = filter(lambda filename: filename, filenames) if filenames: help_required = False if options.submit_bug: for filename in filenames: submit_bug(filename, options) else: for filename in filenames: guess_file(filename, info=options.info.split(','), options=vars(options)) if help_required: # pragma: no cover get_opts().print_help()
def main(): slogging.setupLogging() if PY2: import codecs import locale import sys # see http://bugs.python.org/issue2128 if os.name == "nt": for i, a in enumerate(sys.argv): sys.argv[i] = a.decode(locale.getpreferredencoding()) # see https://github.com/wackou/guessit/issues/43 # and http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file # Wrap sys.stdout into a StreamWriter to allow writing unicode. sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) parser = OptionParser(usage="usage: %prog [options] file1 [file2...]") parser.add_option( "-v", "--verbose", action="store_true", dest="verbose", default=False, help="display debug output" ) parser.add_option( "-p", "--properties", dest="properties", action="store_true", default=False, help="Display properties that can be guessed by the filename matcher.", ) parser.add_option( "-i", "--info", dest="info", default="filename", help="the desired information type: filename, hash_mpc or a hash from python's " "hashlib module, such as hash_md5, hash_sha1, ...; or a list of any of " "them, comma-separated", ) parser.add_option( "-t", "--type", dest="filetype", default="autodetect", help="the suggested file type: movie, episode or autodetect", ) parser.add_option( "-a", "--advanced", dest="advanced", action="store_true", default=False, help="display advanced information for filename guesses, as json output", ) parser.add_option( "-d", "--demo", action="store_true", dest="demo", default=False, help="run a few builtin tests instead of analyzing a file", ) options, args = parser.parse_args() if options.verbose: logging.getLogger().setLevel(logging.DEBUG) transformers.load() if options.properties: display_properties() if options.demo: run_demo(episodes=True, movies=True, advanced=options.advanced) else: if args: for filename in args: detect_filename( filename, filetype=options.filetype, info=options.info.split(","), advanced=options.advanced ) else: parser.print_help()
# README # # run with: # python -m cProfile -o /tmp/profstats bin/test_import.py # view with # runsnake /tmp/profstats from PyQt4.QtGui import QApplication from smewt.base.smewtdaemon import SmewtDaemon from guessit import slogging import sys import smewt import logging slogging.setupLogging() logging.getLogger().setLevel(logging.INFO) log = logging.getLogger(__name__) app = QApplication(sys.argv) app.setOrganizationName(smewt.ORG_NAME) app.setOrganizationDomain('smewt.com') app.setApplicationName(smewt.APP_NAME) s = SmewtDaemon() print len(list(s.database.nodes())) print 'NUM TASKS IN Q:', s.taskManager.queue.qsize()
SMEWTD_INSTANCE = None from appdirs import AppDirs dirs = AppDirs(APP_NAME, ORG_NAME, version=__version__) import logging class NullHandler(logging.Handler): def emit(self, record): pass h = NullHandler() logging.getLogger("smewt").addHandler(h) from guessit.slogging import setupLogging import smewt.config setupLogging(colored=True, with_time=True, with_thread=True) logging.getLogger().setLevel(smewt.config.MAIN_LOGGING_LEVEL) for name, level in smewt.config.LOGGING_LEVELS: logging.getLogger(name).setLevel(level) from smewt.base import SmewtException, SolvingChain, cachedmethod, EventServer, cache, utils, textutils from smewt.ontology import Media, Metadata
def main(args=None, setup_logging=True): if setup_logging: from guessit import slogging slogging.setupLogging() if PY2: # pragma: no cover import codecs import locale import sys # see http://bugs.python.org/issue2128 if os.name == 'nt': for i, a in enumerate(sys.argv): sys.argv[i] = a.decode(locale.getpreferredencoding()) # see https://github.com/wackou/guessit/issues/43 # and http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file # Wrap sys.stdout into a StreamWriter to allow writing unicode. sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) from guessit.plugins import transformers if args: options, args = get_opts().parse_args(args) else: # pragma: no cover options, args = get_opts().parse_args() if options.verbose: logging.getLogger().setLevel(logging.DEBUG) help_required = True if options.properties or options.values: display_properties(options) help_required = False elif options.transformers: display_transformers() help_required = False if options.demo: run_demo(episodes=True, movies=True, options=vars(options)) help_required = False if options.version: print('+-------------------------------------------------------+') print('+ GuessIt ' + __version__ + (28-len(__version__)) * ' ' + '+') print('+-------------------------------------------------------+') print('| Please report any bug or feature request at |') print('| https://github.com/wackou/guessit/issues. |') print('+-------------------------------------------------------+') help_required = False if options.yaml: try: import yaml, babelfish def default_representer(dumper, data): return dumper.represent_str(str(data)) yaml.SafeDumper.add_representer(babelfish.Language, default_representer) yaml.SafeDumper.add_representer(babelfish.Country, default_representer) except ImportError: # pragma: no cover print('PyYAML not found. Using default output.') filenames = [] if args: filenames.extend(args) if options.input_file: input_file = open(options.input_file, 'r') try: filenames.extend([line.strip() for line in input_file.readlines()]) finally: input_file.close() filenames = filter(lambda filename: filename, filenames) if filenames: help_required = False if options.submit_bug: for filename in filenames: submit_bug(filename, options) else: for filename in filenames: guess_file(filename, info=options.info.split(','), options=vars(options)) if help_required: # pragma: no cover get_opts().print_help()
from appdirs import AppDirs dirs = AppDirs(APP_NAME, ORG_NAME, version=__version__) import logging class NullHandler(logging.Handler): def emit(self, record): pass h = NullHandler() logging.getLogger("smewt").addHandler(h) from guessit.slogging import setupLogging import smewt.config setupLogging(colored=True, with_time=True, with_thread=True) logging.getLogger().setLevel(smewt.config.MAIN_LOGGING_LEVEL) for name, level in smewt.config.LOGGING_LEVELS: logging.getLogger(name).setLevel(level) from smewt.base import SmewtException, SolvingChain, cachedmethod, EventServer, cache, utils, textutils from smewt.ontology import Media, Metadata