Esempio n. 1
0
def print_conf(srcMod, fnAttr):
    if config.getDebug(0).lower() == 'true':
        debug_write(srcMod, fnAttr, ['********************************************************']) 
        debug_write(srcMod, fnAttr, ['**  Begin pyTivo Session:', datetime.datetime.today(), ' **']) 
        debug_write(srcMod, fnAttr, ['********************************************************']) 
        debug_write(srcMod, fnAttr, ['----- begin pyTivo.conf -----'])
        conf = open(os.path.join(p, 'pyTivo.conf'))
        for line in conf.readlines():
            if line.strip().startswith('#'):
                continue
            if len(line.strip()) != 0:
                debug_write(srcMod, fnAttr, [line.strip()])
        conf.close()
        debug_write(srcMod, fnAttr, ['------- end pyTivo.conf -----'])
Esempio n. 2
0
def init():
    debug = config.getDebug()
    message("DEBUG LEVEL: " + debug)

    #DEBUG
    if debug == DEBUG_ON or debug == DEBUG_USER or debug == DEBUG_SYSTEM or debug == DEBUG_OFF:
        global DEBUG
        DEBUG = debug

    #OUTFILE
    outfile = config.getOutfile()
    if outfile != "":
        global OUTFILE
        OUTFILE = config.getOutfile()

    #EMAIL
    email_list = config.getEmail()
    addEmailAddr(email_list)
Esempio n. 3
0
def print_conf(srcMod, fnAttr):
    if config.getDebug(0).lower() == 'true':
        debug_write(
            srcMod, fnAttr,
            ['********************************************************'])
        debug_write(
            srcMod, fnAttr,
            ['**  Begin pyTivo Session:',
             datetime.datetime.today(), ' **'])
        debug_write(
            srcMod, fnAttr,
            ['********************************************************'])
        debug_write(srcMod, fnAttr, ['----- begin pyTivo.conf -----'])
        conf = open(os.path.join(p, 'pyTivo.conf'))
        for line in conf.readlines():
            if line.strip().startswith('#'):
                continue
            if len(line.strip()) != 0:
                debug_write(srcMod, fnAttr, [line.strip()])
        conf.close()
        debug_write(srcMod, fnAttr, ['------- end pyTivo.conf -----'])
Esempio n. 4
0
def debug_write(srcMod, fnAttr, data):
    if config.getDebug(0).lower() == 'true':
        debug_out = []
        modname=srcMod.split('.')[-1]
        debug_out.append(modname+'.'+fnAttr[1]+' ['+fnAttr[0]+'] ')
        for x in data:
            debug_out.append(str(x))
        fpath = p
        fname = []
        fname.append('debug')
        if not config.getDebug(1) == '' or not config.getDebug(2) == '':
            if os.path.isdir(config.getDebug(1)):
                fpath = config.getDebug(1)
            fname.append(os.path.split(os.path.dirname(__file__))[-1])
            if config.getDebug(2).lower() == 'split': 
                fname.append(modname)
        fname.append('txt')
        fdebug = open(os.path.join(fpath, '.'.join(fname)), 'a')
        fdebug.write(' '.join(debug_out)+'\n')
        print '___'+' '.join(debug_out)
        fdebug.close()
Esempio n. 5
0
def debug_write(srcMod, fnAttr, data):
    if config.getDebug(0).lower() == 'true':
        debug_out = []
        modname = srcMod.split('.')[-1]
        debug_out.append(modname + '.' + fnAttr[1] + ' [' + fnAttr[0] + '] ')
        for x in data:
            debug_out.append(str(x))
        fpath = p
        fname = []
        fname.append('debug')
        if not config.getDebug(1) == '' or not config.getDebug(2) == '':
            if os.path.isdir(config.getDebug(1)):
                fpath = config.getDebug(1)
            fname.append(os.path.split(os.path.dirname(__file__))[-1])
            if config.getDebug(2).lower() == 'split':
                fname.append(modname)
        fname.append('txt')
        fdebug = open(os.path.join(fpath, '.'.join(fname)), 'a')
        fdebug.write(' '.join(debug_out) + '\n')
        print '___' + ' '.join(debug_out)
        fdebug.close()
Esempio n. 6
0
    def metadata_full(self, full_path, tsn='', mime=''):
        data = {}
        vInfo = transcode.video_info(full_path)

        if ((int(vInfo['vHeight']) >= 720 and
             config.getTivoHeight >= 720) or
            (int(vInfo['vWidth']) >= 1280 and
             config.getTivoWidth >= 1280)):
            data['showingBits'] = '4096'

        data.update(metadata.basic(full_path))
        if full_path[-5:].lower() == '.tivo':
            data.update(metadata.from_tivo(full_path))
        if full_path[-4:].lower() == '.wtv':
            data.update(metadata.from_mscore(vInfo['rawmeta']))

        if 'episodeNumber' in data:
            try:
                ep = int(data['episodeNumber'])
            except:
                ep = 0
            data['episodeNumber'] = str(ep)

        if config.getDebug() and 'vHost' not in data:
            compatible, reason = transcode.tivo_compatible(full_path, tsn, mime)
            if compatible:
                transcode_options = {}
            else:
                transcode_options = transcode.transcode(True, full_path,
                                                        '', tsn, mime)
            data['vHost'] = (
                ['TRANSCODE=%s, %s' % (['YES', 'NO'][compatible], reason)] +
                ['SOURCE INFO: '] +
                ["%s=%s" % (k, v)
                 for k, v in sorted(vInfo.items(), reverse=True)] +
                ['TRANSCODE OPTIONS: '] +
                ["%s" % (v) for k, v in transcode_options.items()] +
                ['SOURCE FILE: ', os.path.basename(full_path)]
            )

        now = datetime.utcnow()
        if 'time' in data:
            if data['time'].lower() == 'file':
                mtime = os.stat(unicode(full_path, 'utf-8')).st_mtime
                if (mtime < 0):
                    mtime = 0
                try:
                    now = datetime.utcfromtimestamp(mtime)
                except:
                    logger.warning('Bad file time on ' + full_path)
            elif data['time'].lower() == 'oad':
                    now = isodt(data['originalAirDate'])
            else:
                try:
                    now = isodt(data['time'])
                except:
                    logger.warning('Bad time format: ' + data['time'] +
                                   ' , using current time')

        duration = self.__duration(full_path)
        duration_delta = timedelta(milliseconds = duration)
        min = duration_delta.seconds / 60
        sec = duration_delta.seconds % 60
        hours = min / 60
        min = min % 60

        data.update({'time': now.isoformat(),
                     'startTime': now.isoformat(),
                     'stopTime': (now + duration_delta).isoformat(),
                     'size': self.__est_size(full_path, tsn, mime),
                     'duration': duration,
                     'iso_duration': ('P%sDT%sH%sM%sS' % 
                          (duration_delta.days, hours, min, sec))})

        return data
Esempio n. 7
0
#!/usr/bin/python3
import os
import gevent.monkey
gevent.monkey.patch_all()
import tornado.web, tornado.wsgi, uimodules
import handlers, persistence
import config

settings = {
    'debug': config.getDebug(),
    'template_path': "views",
    'static_path': 'static',
    'ui_modules': uimodules,
    'cookie_secret': config.getSecrete(),
    "login_url": "/login",
    "xsrf_cookies": True
}
application = tornado.wsgi.WSGIApplication(
    [(r"/", handlers.MainHandler), (r"/login", handlers.LoginFormHandler),
     (r"/authorization", handlers.AuthorizationHandler),
     (r"/signup", handlers.SignUpFormHandler),
     (r"/users", handlers.UserHandler), (r"/logout", handlers.LogoutHandler),
     (r"/notebook", handlers.NotebookHandler),
     (r"/notebook/collections", handlers.CollectionsHandler),
     (r"/notebook/collections/manage", handlers.ManageCollectionsHandler),
     (r"/notebook/collections/new_form", handlers.NewCollectionHandler),
     (r"/notebook/collections/([0-9a-zA-Z\-_%]+)", handlers.CollectionHandler),
     (r"/notebook/collections/([0-9a-zA-Z\-_%]+)/new_form",
      handlers.NewListHandler),
     (r"/notebook/collections/([0-9a-zA-Z\-_%]+)/manage",
      handlers.ListsManageHandler),
Esempio n. 8
0
    def metadata_full(self, full_path, tsn='', mime='', mtime=None):
        data = {}
        vInfo = transcode.video_info(full_path)

        if ((int(vInfo['vHeight']) >= 720 and config.getTivoHeight >= 720) or
            (int(vInfo['vWidth']) >= 1280 and config.getTivoWidth >= 1280)):
            data['showingBits'] = '4096'

        data.update(metadata.basic(full_path, mtime))
        if full_path[-5:].lower() == '.tivo':
            data.update(metadata.from_tivo(full_path))
        if full_path[-4:].lower() == '.wtv':
            data.update(metadata.from_mscore(vInfo['rawmeta']))

        if 'episodeNumber' in data:
            try:
                ep = int(data['episodeNumber'])
            except:
                ep = 0
            data['episodeNumber'] = str(ep)

        if config.getDebug() and 'vHost' not in data:
            compatible, reason = transcode.tivo_compatible(
                full_path, tsn, mime)
            if compatible:
                transcode_options = []
            else:
                transcode_options = transcode.transcode(
                    True, full_path, '', None, False, tsn, mime)
            data['vHost'] = (
                ['TRANSCODE=%s, %s' %
                 (['YES', 'NO'][compatible], reason)] + ['SOURCE INFO: '] + [
                     "%s=%s" % (k, v)
                     for k, v in sorted(vInfo.items(), reverse=True)
                 ] + ['TRANSCODE OPTIONS: '] + transcode_options +
                ['SOURCE FILE: ', os.path.basename(full_path)])

        now = datetime.utcnow()
        if 'time' in data:
            if data['time'].lower() == 'file':
                if not mtime:
                    mtime = os.path.getmtime(unicode(full_path, 'utf-8'))
                try:
                    now = datetime.utcfromtimestamp(mtime)
                except:
                    logger.warning('Bad file time on ' + full_path)
            elif data['time'].lower() == 'oad':
                now = isodt(data['originalAirDate'])
            else:
                try:
                    now = isodt(data['time'])
                except:
                    logger.warning('Bad time format: ' + data['time'] +
                                   ' , using current time')

        duration = self.__duration(full_path)
        duration_delta = timedelta(milliseconds=duration)
        min = duration_delta.seconds / 60
        sec = duration_delta.seconds % 60
        hours = min / 60
        min = min % 60

        data.update({
            'time':
            now.isoformat(),
            'startTime':
            now.isoformat(),
            'stopTime': (now + duration_delta).isoformat(),
            'size':
            self.__est_size(full_path, tsn, mime),
            'duration':
            duration,
            'iso_duration':
            ('P%sDT%sH%sM%sS' % (duration_delta.days, hours, min, sec))
        })

        return data
Esempio n. 9
0
#!/usr/bin/python3
import os
import gevent.monkey
gevent.monkey.patch_all()
import tornado.web, tornado.wsgi, uimodules
import handlers, persistence
import config
import caching

settings = {
	'debug': config.getDebug(), 
	'template_path': "views", 
	'static_path': 'static',
	'ui_modules': uimodules,
	'cookie_secret': config.getSecrete(),
	"login_url": "/login",
	"xsrf_cookies": True
}
application = tornado.wsgi.WSGIApplication([
	(r"/", handlers.MainHandler),
	(r"/login", handlers.LoginFormHandler),
	(r"/authorization", handlers.AuthorizationHandler),
	(r"/signup", handlers.SignUpFormHandler),
	(r"/users", handlers.UserHandler),
	(r"/logout", handlers.LogoutHandler),
	(r"/notebook", handlers.NotebookHandler),
	(r"/notebook/collections", handlers.CollectionsHandler),
	(r"/notebook/collections/manage", handlers.ManageCollectionsHandler),
	(r"/notebook/collections/new_form", handlers.NewCollectionHandler),
	(r"/notebook/collections/([0-9a-zA-Z\-_%]+)", handlers.CollectionHandler),
	(r"/notebook/collections/([0-9a-zA-Z\-_%]+)/new_form", handlers.NewListHandler),
Esempio n. 10
0
    def metadata_full(self, full_path, tsn="", mime=""):
        data = {}
        vInfo = transcode.video_info(full_path)

        if (int(vInfo["vHeight"]) >= 720 and config.getTivoHeight >= 720) or (
            int(vInfo["vWidth"]) >= 1280 and config.getTivoWidth >= 1280
        ):
            data["showingBits"] = "4096"

        data.update(metadata.basic(full_path))
        if full_path[-5:].lower() == ".tivo":
            data.update(metadata.from_tivo(full_path))
        if full_path[-4:].lower() == ".wtv":
            data.update(metadata.from_mscore(vInfo["rawmeta"]))

        if "episodeNumber" in data:
            try:
                ep = int(data["episodeNumber"])
            except:
                ep = 0
            data["episodeNumber"] = str(ep)

        if config.getDebug() and "vHost" not in data:
            compatible, reason = transcode.tivo_compatible(full_path, tsn, mime)
            if compatible:
                transcode_options = {}
            else:
                transcode_options = transcode.transcode(True, full_path, "", tsn, mime)
            data["vHost"] = (
                ["TRANSCODE=%s, %s" % (["YES", "NO"][compatible], reason)]
                + ["SOURCE INFO: "]
                + ["%s=%s" % (k, v) for k, v in sorted(vInfo.items(), reverse=True)]
                + ["TRANSCODE OPTIONS: "]
                + ["%s" % (v) for k, v in transcode_options.items()]
                + ["SOURCE FILE: ", os.path.basename(full_path)]
            )

        now = datetime.utcnow()
        if "time" in data:
            if data["time"].lower() == "file":
                mtime = os.stat(unicode(full_path, "utf-8")).st_mtime
                if mtime < 0:
                    mtime = 0
                try:
                    now = datetime.utcfromtimestamp(mtime)
                except:
                    logger.warning("Bad file time on " + full_path)
            elif data["time"].lower() == "oad":
                now = isodt(data["originalAirDate"])
            else:
                try:
                    now = isodt(data["time"])
                except:
                    logger.warning("Bad time format: " + data["time"] + " , using current time")

        duration = self.__duration(full_path)
        duration_delta = timedelta(milliseconds=duration)
        min = duration_delta.seconds / 60
        sec = duration_delta.seconds % 60
        hours = min / 60
        min = min % 60

        data.update(
            {
                "time": now.isoformat(),
                "startTime": now.isoformat(),
                "stopTime": (now + duration_delta).isoformat(),
                "size": self.__est_size(full_path, tsn, mime),
                "duration": duration,
                "iso_duration": ("P%sDT%sH%sM%sS" % (duration_delta.days, hours, min, sec)),
            }
        )

        return data