• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python transcode.supported_format函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中transcode.supported_format函数的典型用法代码示例。如果您正苦于以下问题:Python supported_format函数的具体用法?Python supported_format怎么用?Python supported_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了supported_format函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: video_file_filter

 def video_file_filter(self, full_path, type=None):
     if os.path.isdir(full_path):
         return True
     if extensions:
         return os.path.splitext(full_path)[1].lower() in extensions
     else:
         return transcode.supported_format(full_path)
开发者ID:armooo,项目名称:pytivo,代码行数:7,代码来源:video.py


示例2: video_file_filter

 def video_file_filter(self, full_path, type=None):
     if os.path.isdir(unicode(full_path, 'utf-8')):
         return True
     if use_extensions:
         return os.path.splitext(full_path)[1].lower() in EXTENSIONS
     else:
         return transcode.supported_format(full_path)
开发者ID:thspencer,项目名称:pyTivo-Taylor,代码行数:7,代码来源:video.py


示例3: push_one_file

    def push_one_file(self, f):
        file_info = VideoDetails()
        file_info['valid'] = transcode.supported_format(f['path'])

        temp_share = config.get_server('temp_share', '')
        temp_share_path = ''
        if temp_share:
            for name, data in config.getShares():
                if temp_share == name:
                    temp_share_path = data.get('path')

        mime = 'video/mpeg'
        if config.isHDtivo(f['tsn']):
            for m in ['video/mp4', 'video/bif']:
                if transcode.tivo_compatible(f['path'], f['tsn'], m)[0]:
                    mime = m
                    break

            if (mime == 'video/mpeg' and
                transcode.mp4_remuxable(f['path'], f['tsn'])):
                new_path = transcode.mp4_remux(f['path'], f['name'], f['tsn'], temp_share_path)
                if new_path:
                    mime = 'video/mp4'
                    f['name'] = new_path
                    if temp_share_path:
                        ip = config.get_ip()
                        port = config.getPort()
                        container = quote(temp_share) + '/'
                        f['url'] = 'http://%s:%s/%s' % (ip, port, container)

        if file_info['valid']:
            file_info.update(self.metadata_full(f['path'], f['tsn'], mime))

        url = f['url'] + quote(f['name'])

        title = file_info['seriesTitle']
        if not title:
            title = file_info['title']

        source = file_info['seriesId']
        if not source:
            source = title

        subtitle = file_info['episodeTitle']
        try:
            m = mind.getMind(f['tsn'])
            m.pushVideo(
                tsn = f['tsn'],
                url = url,
                description = file_info['description'],
                duration = file_info['duration'] / 1000,
                size = file_info['size'],
                title = title,
                subtitle = subtitle,
                source = source,
                mime = mime,
                tvrating = file_info['tvRating'])
        except Exception, msg:
            logger.error(msg)
开发者ID:josefarv,项目名称:pytivo_lucasnz_mirror,代码行数:59,代码来源:video.py


示例4: get_details_xml

    def get_details_xml(self, tsn, file_path):
        if (tsn, file_path) in self.tvbus_cache:
            details = self.tvbus_cache[(tsn, file_path)]
        else:
            file_info = VideoDetails()
            file_info['valid'] = transcode.supported_format(file_path)
            if file_info['valid']:
                file_info.update(self.metadata_full(file_path, tsn))

            t = Template(TVBUS_TEMPLATE, filter=EncodeUnicode)
            t.video = file_info
            t.escape = escape
            details = str(t)
            self.tvbus_cache[(tsn, file_path)] = details
        return details
开发者ID:Gimpson,项目名称:pytivo,代码行数:15,代码来源:video.py


示例5: push_one_file

    def push_one_file(self, f):
        file_info = VideoDetails()
        file_info["valid"] = transcode.supported_format(f["path"])

        mime = "video/mpeg"
        if config.isHDtivo(f["tsn"]):
            for m in ["video/mp4", "video/bif"]:
                if transcode.tivo_compatible(f["path"], f["tsn"], m)[0]:
                    mime = m
                    break

            if mime == "video/mpeg" and transcode.mp4_remuxable(f["path"], f["tsn"]):
                new_path = transcode.mp4_remux(f["path"], f["name"], f["tsn"])
                if new_path:
                    mime = "video/mp4"
                    f["name"] = new_path

        if file_info["valid"]:
            file_info.update(self.metadata_full(f["path"], f["tsn"], mime))

        url = f["url"] + quote(f["name"])

        title = file_info["seriesTitle"]
        if not title:
            title = file_info["title"]

        source = file_info["seriesId"]
        if not source:
            source = title

        subtitle = file_info["episodeTitle"]
        try:
            m = mind.getMind(f["tsn"])
            m.pushVideo(
                tsn=f["tsn"],
                url=url,
                description=file_info["description"],
                duration=file_info["duration"] / 1000,
                size=file_info["size"],
                title=title,
                subtitle=subtitle,
                source=source,
                mime=mime,
                tvrating=file_info["tvRating"],
            )
        except Exception, msg:
            logger.error(msg)
开发者ID:WeekdayFiller,项目名称:pytivo,代码行数:47,代码来源:video.py


示例6: push_one_file

    def push_one_file(self, f):
        file_info = VideoDetails()
        file_info['valid'] = transcode.supported_format(f['path'])

        mime = 'video/mpeg'
        if config.isHDtivo(f['tsn']):
            for m in ['video/mp4', 'video/bif']:
                if transcode.tivo_compatible(f['path'], f['tsn'], m)[0]:
                    mime = m
                    break

            if (mime == 'video/mpeg' and
                transcode.mp4_remuxable(f['path'], f['tsn'])):
                new_path = transcode.mp4_remux(f['path'], f['name'], f['tsn'])
                if new_path:
                    mime = 'video/mp4'
                    f['name'] = new_path

        if file_info['valid']:
            file_info.update(self.metadata_full(f['path'], f['tsn'], mime))

        url = f['url'] + quote(f['name'])

        title = file_info['seriesTitle']
        if not title:
            title = file_info['title']

        source = file_info['seriesId']
        if not source:
            source = title

        subtitle = file_info['episodeTitle']
        try:
            m = mind.getMind(f['tsn'])
            m.pushVideo(
                tsn = f['tsn'],
                url = url,
                description = file_info['description'],
                duration = file_info['duration'] / 1000,
                size = file_info['size'],
                title = title,
                subtitle = subtitle,
                source = source,
                mime = mime,
                tvrating = file_info['tvRating'])
        except Exception, msg:
            logger.error(msg)
开发者ID:wynneth,项目名称:pytivo,代码行数:47,代码来源:video.py


示例7: TVBusQuery

    def TVBusQuery(self, handler, query):
        tsn = handler.headers.getheader('tsn', '')       
        file = query['File'][0]
        path = self.get_local_path(handler, query)
        file_path = path + file

        file_info = VideoDetails()
        file_info['valid'] = transcode.supported_format(file_path)
        if file_info['valid']:
            file_info.update(self.__metadata_full(file_path, tsn))

        handler.send_response(200)
        handler.end_headers()
        t = Template(file=os.path.join(SCRIPTDIR,'templates', 'TvBus.tmpl'))
        t.video = file_info
        t.escape = escape
        handler.wfile.write(t)
开发者ID:armooo,项目名称:pytivo,代码行数:17,代码来源:video.py


示例8: Push

    def Push(self, handler, query):
        file = unquote(query['File'][0])
        tsn = query['tsn'][0]
        path = self.get_local_path(handler, query)
        file_path = path + file

        file_info = VideoDetails()
        file_info['valid'] = transcode.supported_format(file_path)
        if file_info['valid']:
            file_info.update(self.__metadata_full(file_path, tsn))

        import socket
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('tivo.com',123))
        ip = s.getsockname()[0]
        container = quote(query['Container'][0].split('/')[0])
        port = config.getPort()

        url = 'http://%s:%s/%s%s' % (ip, port, container, quote(file))

        print 'tsn', tsn
        print 'url', url
        print query

        username = config.getTivoUsername()
        password = config.getTivoPassword()

        if not username or not password:
            raise Exception("tivo_username and tivo_password required")

        try:
            m = mind.Mind(username, password, True)
            m.pushVideo(
                tsn = tsn, 
                url = url, 
                description = file_info['description'],
                duration = file_info['duration'] / 1000,
                size = file_info['size'],
                title = file_info['title'],
                subtitle = file_info['name'])
        except Exception, e:
            import traceback
            handler.send_response(500)
            handler.end_headers()
            handler.wfile.write('%s\n\n%s' % (e, traceback.format_exc() ))
            raise
开发者ID:armooo,项目名称:pytivo,代码行数:46,代码来源:video.py


示例9: __total_items

 def __total_items(self, full_path):
     count = 0
     try:
         for file in os.listdir(full_path):
             if file.startswith('.'):
                 continue
             file = os.path.join(full_path, file)
             if os.path.isdir(file):
                 count += 1
             elif extensions:
                 if os.path.splitext(file)[1].lower() in extensions:
                     count += 1
             elif file in transcode.info_cache:
                 if transcode.supported_format(file):
                     count += 1
     except:
         pass
     return count
开发者ID:armooo,项目名称:pytivo,代码行数:18,代码来源:video.py


示例10: __total_items

 def __total_items(self, full_path):
     count = 0
     try:
         full_path = unicode(full_path, 'utf-8')
         for f in os.listdir(full_path):
             if f.startswith('.'):
                 continue
             f = os.path.join(full_path, f)
             f2 = f.encode('utf-8')
             if os.path.isdir(f):
                 count += 1
             elif use_extensions:
                 if os.path.splitext(f2)[1].lower() in EXTENSIONS:
                     count += 1
             elif f2 in transcode.info_cache:
                 if transcode.supported_format(f2):
                     count += 1
     except:
         pass
     return count
开发者ID:thspencer,项目名称:pyTivo-Taylor,代码行数:20,代码来源:video.py


示例11: pre_cache

 def pre_cache(self, full_path):
     if Video.video_file_filter(self, full_path):
         transcode.supported_format(full_path)
开发者ID:thspencer,项目名称:pyTivo-Taylor,代码行数:3,代码来源:video.py


示例12: QueryContainer

    def QueryContainer(self, handler, query):
        tsn = handler.headers.getheader('tsn', '')
        subcname = query['Container'][0]

        if not self.get_local_path(handler, query):
            handler.send_error(404)
            return

        container = handler.container
        force_alpha = container.getboolean('force_alpha')
        ar = container.get('allow_recurse', 'auto').lower()
        if ar == 'auto':
            allow_recurse = not tsn or tsn[0] < '7'
        else:
            allow_recurse = ar in ('1', 'yes', 'true', 'on')
        use_html = query.get('Format', [''])[0].lower() == 'text/html'

        files, total, start = self.get_files(handler, query,
                                             self.video_file_filter,
                                             force_alpha, allow_recurse)

        videos = []
        local_base_path = self.get_local_base_path(handler, query)
        resort = False
        for f in files:
            video = VideoDetails()
            mtime = f.mdate
            try:
                ltime = time.localtime(mtime)
            except:
                logger.warning('Bad file time on ' + unicode(f.name, 'utf-8'))
                mtime = time.time()
                ltime = time.localtime(mtime)
            video['captureDate'] = hex(int(mtime))
            video['textDate'] = time.strftime('%b %d, %Y', ltime)
            video['name'] = os.path.basename(f.name)
            video['path'] = f.name
            video['part_path'] = f.name.replace(local_base_path, '', 1)
            if not video['part_path'].startswith(os.path.sep):
                video['part_path'] = os.path.sep + video['part_path']
            video['title'] = os.path.basename(f.name)
            video['is_dir'] = f.isdir
            if video['is_dir']:
                video['small_path'] = subcname + '/' + video['name']
                video['total_items'] = self.__total_items(f.name)
            else:
                if len(files) == 1 or f.name in transcode.info_cache:
                    video['valid'] = transcode.supported_format(f.name)
                    if video['valid']:
                        video.update(self.metadata_full(f.name, tsn,
                                     mtime=mtime))
                        if len(files) == 1:
                            video['captureDate'] = hex(isogm(video['time']))
                else:
                    video['valid'] = True
                    video.update(metadata.basic(f.name, mtime))

                if 'time' in video and video['time'] != '':
                    if video['time'].lower() == 'oad':
                        video['time'] = video['originalAirDate']
                        resort = True
                    try:
                        video['captureDate'] = hex(isogm(video['time']))
                        video['textDate'] = time.strftime('%b %d, %Y', time.localtime(isogm(video['time'])))
                        resort = True
                    except:
                        logger.warning('Bad time format: "' + video['time'] +
                                       '", using current time')

                if self.use_ts(tsn, f.name):
                    video['mime'] = 'video/x-tivo-mpeg-ts'
                else:
                    video['mime'] = 'video/x-tivo-mpeg'

                video['textSize'] = metadata.human_size(f.size)

            videos.append(video)

        if use_html:
            t = Template(HTML_CONTAINER_TEMPLATE, filter=EncodeUnicode)
        else:
            t = Template(XML_CONTAINER_TEMPLATE, filter=EncodeUnicode)

        sortby = query.get('SortOrder', ['Normal'])[0].lower()
        t.sortby = sortby
        if use_html and resort:
            if sortby == 'capturedate':
                logger.info('re-sorting by captureDate, reverse=True')
                videos.sort(key=itemgetter('captureDate'), reverse=True)
            elif sortby == '!capturedate':
                logger.info('re-sorting by captureDate, reverse=False')
                videos.sort(key=itemgetter('captureDate'), reverse=False)

        t.container = handler.cname
        t.name = subcname
        t.total = total
        t.start = start
        t.videos = videos
        t.quote = quote
        t.escape = escape
#.........这里部分代码省略.........
开发者ID:driver8x,项目名称:pytivo,代码行数:101,代码来源:video.py


示例13: QueryContainer

    def QueryContainer(self, handler, query):
        tsn = handler.headers.getheader('tsn', '')
        subcname = query['Container'][0]
        cname = subcname.split('/')[0]

        if (not cname in handler.server.containers or
            not self.get_local_path(handler, query)):
            handler.send_error(404)
            return

        container = handler.server.containers[cname]
        precache = container.get('precache', 'False').lower() == 'true'
        force_alpha = container.get('force_alpha', 'False').lower() == 'true'

        files, total, start = self.get_files(handler, query,
                                             self.video_file_filter,
                                             force_alpha)

        videos = []
        local_base_path = self.get_local_base_path(handler, query)
        for f in files:
            video = VideoDetails()
            mtime = f.mdate
            try:
                ltime = time.localtime(mtime)
            except:
                logger.warning('Bad file time on ' + unicode(f.name, 'utf-8'))
                mtime = int(time.time())
                ltime = time.localtime(mtime)
            video['captureDate'] = hex(mtime)
            video['textDate'] = time.strftime('%b %d, %Y', ltime)
            video['name'] = os.path.split(f.name)[1]
            video['path'] = f.name
            video['part_path'] = f.name.replace(local_base_path, '', 1)
            if not video['part_path'].startswith(os.path.sep):
                video['part_path'] = os.path.sep + video['part_path']
            video['title'] = os.path.split(f.name)[1]
            video['is_dir'] = f.isdir
            if video['is_dir']:
                video['small_path'] = subcname + '/' + video['name']
                video['total_items'] = self.__total_items(f.name)
            else:
                if precache or len(files) == 1 or f.name in transcode.info_cache:
                    video['valid'] = transcode.supported_format(f.name)
                    if video['valid']:
                        video.update(self.metadata_full(f.name, tsn))
                else:
                    video['valid'] = True
                    video.update(metadata.basic(f.name))

                video['textSize'] = ( '%.3f GB' %
                    (float(f.size) / (1024 ** 3)) )

            videos.append(video)

        t = Template(CONTAINER_TEMPLATE, filter=EncodeUnicode)
        t.container = cname
        t.name = subcname
        t.total = total
        t.start = start
        t.videos = videos
        t.quote = quote
        t.escape = escape
        t.crc = zlib.crc32
        t.guid = config.getGUID()
        t.tivos = config.tivos
        t.tivo_names = config.tivo_names
        handler.send_response(200)
        handler.send_header('Content-Type', 'text/xml')
        handler.send_header('Expires', '0')
        handler.end_headers()
        handler.wfile.write(t)
开发者ID:Gimpson,项目名称:pytivo,代码行数:72,代码来源:video.py


示例14: Push

    def Push(self, handler, query):
        tsn = query['tsn'][0]
        for key in config.tivo_names:
            if config.tivo_names[key] == tsn:
                tsn = key
                break
        tivo_name = config.tivo_names.get(tsn, tsn)

        container = quote(query['Container'][0].split('/')[0])
        ip = config.get_ip()
        port = config.getPort()

        baseurl = 'http://%s:%s' % (ip, port)
        if config.getIsExternal(tsn):
            exturl = config.get_server('externalurl')
            if exturl:
                baseurl = exturl
            else:
                ip = self.readip()
                baseurl = 'http://%s:%s' % (ip, port)
 
        path = self.get_local_base_path(handler, query)

        files = query.get('File', [])
        for f in files:
            file_path = path + os.path.normpath(f)

            file_info = VideoDetails()
            file_info['valid'] = transcode.supported_format(file_path)

            mime = 'video/mpeg'
            if config.isHDtivo(tsn):
                for m in ['video/mp4', 'video/bif']:
                    if transcode.tivo_compatible(file_path, tsn, m)[0]:
                        mime = m
                        break

            if file_info['valid']:
                file_info.update(self.metadata_full(file_path, tsn, mime))

            url = baseurl + '/%s%s' % (container, quote(f))

            title = file_info['seriesTitle']
            if not title:
                title = file_info['title']

            source = file_info['seriesId']
            if not source:
                source = title

            subtitle = file_info['episodeTitle']
            try:
                m = mind.getMind(tsn)
                m.pushVideo(
                    tsn = tsn,
                    url = url,
                    description = file_info['description'],
                    duration = file_info['duration'] / 1000,
                    size = file_info['size'],
                    title = title,
                    subtitle = subtitle,
                    source = source,
                    mime = mime,
                    tvrating = file_info['tvRating'])
            except Exception, e:
                handler.send_response(500)
                handler.end_headers()
                handler.wfile.write('%s\n\n%s' % (e, traceback.format_exc() ))
                raise

            logger.info('[%s] Queued "%s" for Push to %s' %
                        (time.strftime('%d/%b/%Y %H:%M:%S'),
                         unicode(file_path, 'utf-8'), tivo_name))
开发者ID:Gimpson,项目名称:pytivo,代码行数:73,代码来源:video.py


示例15: QueryContainer

    def QueryContainer(self, handler, query):
        tsn = handler.headers.getheader('tsn', '')
        subcname = query['Container'][0]

        if not self.get_local_path(handler, query):
            handler.send_error(404)
            return

        container = handler.container
        force_alpha = container.getboolean('force_alpha')
        ar = container.get('allow_recurse', 'auto').lower()
        if ar == 'auto':
            allow_recurse = not tsn or tsn[0] < '7'
        else:
            allow_recurse = ar in ('1', 'yes', 'true', 'on')

        files, total, start = self.get_files(handler, query,
                                             self.video_file_filter,
                                             force_alpha, allow_recurse)

        videos = []
        local_base_path = self.get_local_base_path(handler, query)
        for f in files:
            video = VideoDetails()
            mtime = f.mdate
            try:
                ltime = time.localtime(mtime)
            except:
                logger.warning('Bad file time on ' + unicode(f.name, 'utf-8'))
                mtime = time.time()
                ltime = time.localtime(mtime)
            video['captureDate'] = hex(int(mtime))
            video['textDate'] = time.strftime('%b %d, %Y', ltime)
            video['name'] = os.path.basename(f.name)
            video['path'] = f.name
            video['part_path'] = f.name.replace(local_base_path, '', 1)
            if not video['part_path'].startswith(os.path.sep):
                video['part_path'] = os.path.sep + video['part_path']
            video['title'] = os.path.basename(f.name)
            video['is_dir'] = f.isdir
            if video['is_dir']:
                video['small_path'] = subcname + '/' + video['name']
                video['total_items'] = self.__total_items(f.name)
            else:
                if len(files) == 1 or f.name in transcode.info_cache:
                    video['valid'] = transcode.supported_format(f.name)
                    if video['valid']:
                        video.update(self.metadata_full(f.name, tsn,
                                     mtime=mtime))
                        if len(files) == 1:
                            video['captureDate'] = hex(isogm(video['time']))
                else:
                    video['valid'] = True
                    video.update(metadata.basic(f.name, mtime))

                if self.use_ts(tsn, f.name):
                    video['mime'] = 'video/x-tivo-mpeg-ts'
                else:
                    video['mime'] = 'video/x-tivo-mpeg'

                video['textSize'] = metadata.human_size(f.size)

            videos.append(video)

        t = Template(XML_CONTAINER_TEMPLATE, filter=EncodeUnicode)
        t.container = handler.cname
        t.name = subcname
        t.total = total
        t.start = start
        t.videos = videos
        t.quote = quote
        t.escape = escape
        t.crc = zlib.crc32
        t.guid = config.getGUID()
        t.tivos = config.tivos
        handler.send_xml(str(t))
开发者ID:ertyu,项目名称:pytivo,代码行数:76,代码来源:video.py


示例16: QueryContainer

    def QueryContainer(self, handler, query):
        tsn = handler.headers.getheader('tsn', '')
        subcname = query['Container'][0]

        # If you are running 8.3 software you want to enable hack83
        # in the config file
        if config.getHack83():
            print '=' * 73
            query, hackPath = self.hack(handler, query, subcname)
            hackPath = '/'.join(hackPath)
            print 'Tivo said:', subcname, '|| Hack said:', hackPath
            debug_write(__name__, fn_attr(), ['Tivo said: ', subcname, ' || Hack said: ',
                         hackPath])
            subcname = hackPath

            if not query:
                debug_write(__name__, fn_attr(), ['sending 302 redirect page'])
                handler.send_response(302)
                handler.send_header('Location ', 'http://' +
                                    handler.headers.getheader('host') +
                                    '/TiVoConnect?Command=QueryContainer&' +
                                    'AnchorItem=Hack8.3&Container=' + hackPath)
                handler.end_headers()
                return

        # End hack mess

        cname = subcname.split('/')[0]

        if not handler.server.containers.has_key(cname) or \
           not self.get_local_path(handler, query):
            handler.send_response(404)
            handler.end_headers()
            return

        container = handler.server.containers[cname]
        precache = container.get('precache', 'False').lower() == 'true'

        files, total, start = self.get_files(handler, query,
                                             self.video_file_filter)

        videos = []
        local_base_path = self.get_local_base_path(handler, query)
        for file in files:
            mtime = datetime.fromtimestamp(os.stat(file).st_mtime)
            video = VideoDetails()
            video['captureDate'] = hex(int(time.mktime(mtime.timetuple())))
            video['name'] = os.path.split(file)[1]
            video['path'] = file
            video['part_path'] = file.replace(local_base_path, '', 1)
            video['title'] = os.path.split(file)[1]
            video['is_dir'] = self.__isdir(file)
            if video['is_dir']:
                video['small_path'] = subcname + '/' + video['name']
                video['total_items'] = self.__total_items(file)
            else:
                if precache or len(files) == 1 or file in transcode.info_cache:
                    video['valid'] = transcode.supported_format(file)
                    if video['valid']:
                        video.update(self.__metadata_full(file, tsn))
                else:
                    video['valid'] = True
                    video.update(self.__metadata_basic(file))

            videos.append(video)

        handler.send_response(200)
        handler.end_headers()
        t = Template(file=os.path.join(SCRIPTDIR,'templates', 'container.tmpl'))
        t.container = cname
        t.name = subcname
        t.total = total
        t.start = start
        t.videos = videos
        t.quote = quote
        t.escape = escape
        t.crc = zlib.crc32
        t.guid = config.getGUID()
        t.tivos = handler.tivos
        handler.wfile.write(t)
开发者ID:armooo,项目名称:pytivo,代码行数:80,代码来源:video.py


示例17: QueryContainer

    def QueryContainer(self, handler, query):
        tsn = handler.headers.getheader('tsn', '')
        subcname = query['Container'][0]
        useragent = handler.headers.getheader('User-Agent', '')

        if not self.get_local_path(handler, query):
            handler.send_error(404)
            return

        container = handler.container
        force_alpha = container.getboolean('force_alpha')
        use_html = query.get('Format', [''])[0].lower() == 'text/html'

        files, total, start = self.get_files(handler, query,
                                             self.video_file_filter,
                                             force_alpha)

        videos = []
        local_base_path = self.get_local_base_path(handler, query)
        for f in files:
            video = VideoDetails()
            mtime = f.mdate
            try:
                ltime = time.localtime(mtime)
            except:
                logger.warning('Bad file time on ' + unicode(f.name, 'utf-8'))
                mtime = int(time.time())
                ltime = time.localtime(mtime)
            video['captureDate'] = hex(mtime)
            video['textDate'] = time.strftime('%b %d, %Y', ltime)
            video['name'] = os.path.basename(f.name)
            video['path'] = f.name
            video['part_path'] = f.name.replace(local_base_path, '', 1)
            if not video['part_path'].startswith(os.path.sep):
                video['part_path'] = os.path.sep + video['part_path']
            video['title'] = os.path.basename(f.name)
            video['is_dir'] = f.isdir
            if video['is_dir']:
                video['small_path'] = subcname + '/' + video['name']
                video['total_items'] = self.__total_items(f.name)
            else:
                if len(files) == 1 or f.name in transcode.info_cache:
                    video['valid'] = transcode.supported_format(f.name)
                    if video['valid']:
                        video.update(self.metadata_full(f.name, tsn))
                        if len(files) == 1:
                            video['captureDate'] = hex(isogm(video['time']))
                else:
                    video['valid'] = True
                    video.update(metadata.basic(f.name))

                if self.use_ts(tsn, f.name):
                    video['mime'] = 'video/x-tivo-mpeg-ts'
                else:
                    video['mime'] = 'video/x-tivo-mpeg'

                video['textSize'] = metadata.human_size(f.size)

            videos.append(video)

        logger.debug('mobileagent: %d useragent: %s' % (useragent.lower().find('mobile'), useragent.lower()))
        use_mobile = useragent.lower().find('mobile') > 0
        if use_html:
            if use_mobile:
                t = Template(HTML_CONTAINER_TEMPLATE_MOBILE, filter=EncodeUnicode)
            else:
                t = Template(HTML_CONTAINER_TEMPLATE, filter=EncodeUnicode)
        else:
            t = Template(XML_CONTAINER_TEMPLATE, filter=EncodeUnicode)

        t.container = handler.cname
        t.name = subcname
        t.total = total
        t.start = start
        t.videos = videos
        t.quote = quote
        t.escape = escape
        t.crc = zlib.crc32
        t.guid = config.getGUID()
        t.tivos = config.tivos
        t.tivo_names = config.tivo_names
        if use_html:
            handler.send_html(str(t))
        else:
            handler.send_xml(str(t))
开发者ID:thspencer,项目名称:pyTivo-Taylor,代码行数:85,代码来源:video.py


示例18: push_one_file

    def push_one_file(self, f):
        file_info = VideoDetails()
        file_info['valid'] = transcode.supported_format(f['path'])

        temp_share = config.get_server('temp_share', '')
        temp_share_path = ''
        remux_path = os.path.dirname(f['path'])
        if temp_share:
            for name, data in config.getShares():
                if temp_share == name:
                    temp_share_path = data.get('path')
                    remux_path = temp_share_path

        mime = 'video/mpeg'
        if config.isHDtivo(f['tsn']):
            for m in ['video/mp4', 'video/bif']:
                if transcode.tivo_compatible(f['path'], f['tsn'], m)[0]:
                    mime = m
                    break

            if (mime == 'video/mpeg' and
                transcode.mp4_remuxable(f['path'], f['tsn'])):
                if config.get_freeSpace(remux_path, f['path']):
                    new_path = transcode.mp4_remux(f['path'], f['name'], f['tsn'], temp_share_path)
                    if new_path:
                        mime = 'video/mp4'
                        f['name'] = new_path
                        if temp_share_path:
                            ip = config.get_ip()
                            port = config.getPort()
                            container = quote(temp_share) + '/'
                            f['url'] = 'http://%s:%s/%s' % (ip, port, container)
                else:
                    logger.warning('Not enough disk space to perform remux, ' +
                                   'transcoding instead.')

        if file_info['valid']:
            file_info.update(self.metadata_full(f['path'], f['tsn'], mime))

        url = f['url'] + quote(f['name'])

        title = file_info['seriesTitle']
        if not title:
            title = file_info['title']

        source = file_info['seriesId']
        if not source:
            source = title

        subtitle = file_info['episodeTitle']
        try:
            m = mind.getMind(f['tsn'])
            m.pushVideo(
                tsn = f['tsn'],
                url = url,
                description = file_info['description'],
                duration = file_info['duration'] / 1000,
                size = file_info['size'],
                title = title,
                subtitle = subtitle,
                source = source,
                mime = mime,
                tvrating = file_info['tvRating'])
        except ValueError, msg:
            if 'usernamePasswordError' in msg:
                if f['name'].endswith('.pyTivo-temp'):
                    fname = os.path.join(remux_path, os.path.basename(f['name']))
                    fname = unicode(fname, 'utf-8')
                    os.remove(fname)
                    logger.debug(fname + ' has been removed')
开发者ID:thspencer,项目名称:pyTivo-Taylor,代码行数:70,代码来源:video.py


示例19: QueryContainer

    def QueryContainer(self, handler, query):
        tsn = handler.headers.getheader("tsn", "")
        subcname = query["Container"][0]

        if not self.get_local_path(handler, query):
            handler.send_error(404)
            return

        container = handler.container
        force_alpha = container.get("force_alpha", "False").lower() == "true"
        use_html = query.get("Format", [""])[0].lower() == "text/html"

        files, total, start = self.get_files(handler, query, self.video_file_filter, force_alpha)

        videos = []
        local_base_path = self.get_local_base_path(handler, query)
        for f in files:
            video = VideoDetails()
            mtime = f.mdate
            try:
                ltime = time.localtime(mtime)
            except:
                logger.warning("Bad file time on " + unicode(f.name, "utf-8"))
                mtime = int(time.time())
                ltime = time.localtime(mtime)
            video["captureDate"] = hex(mtime)
            video["textDate"] = time.strftime("%b %d, %Y", ltime)
            video["name"] = os.path.basename(f.name)
            video["path"] = f.name
            video["part_path"] = f.name.replace(local_base_path, "", 1)
            if not video["part_path"].startswith(os.path.sep):
                video["part_path"] = os.path.sep + video["part_path"]
            video["title"] = os.path.basename(f.name)
            video["is_dir"] = f.isdir
            if video["is_dir"]:
                video["small_path"] = subcname + "/" + video["name"]
                video["total_items"] = self.__total_items(f.name)
            else:
                if len(files) == 1 or f.name in transcode.info_cache:
                    video["valid"] = transcode.supported_format(f.name)
                    if video["valid"]:
                        video.update(self.metadata_full(f.name, tsn))
                        if len(files) == 1:
                            video["captureDate"] = hex(isogm(video["time"]))
                else:
                    video["valid"] = True
                    video.update(metadata.basic(f.name))

                if self.use_ts(tsn, f.name):
                    video["mime"] = "video/x-tivo-mpeg-ts"
                else:
                    video["mime"] = "video/x-tivo-mpeg"

                video["textSize"] = "%.3f GB" % (float(f.size) / (1024 ** 3))

            videos.append(video)

        if use_html:
            t = Template(HTML_CONTAINER_TEMPLATE, filter=EncodeUnicode)
        else:
            t = Template(XML_CONTAINER_TEMPLATE, filter=EncodeUnicode)
        t.container = handler.cname
        t.name = subcname
        t.total = total
        t.start = start
        t.videos = videos
        t.quote = quote
        t.escape = escape
        t.crc = zlib.crc32
        t.guid = config.getGUID()
        t.tivos = config.tivos
        t.tivo_names = config.tivo_names
        if use_html:
            handler.send_html(str(t))
        else:
            handler.send_xml(str(t))
开发者ID:WeekdayFiller,项目名称:pytivo,代码行数:76,代码来源:video.py



注:本文中的transcode.supported_format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python transcode.tivo_compatible函数代码示例发布时间:2022-05-27
下一篇:
Python weakset.WeakSet类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap