本文整理汇总了Python中Cheetah.Template.Template.togo_mpegts方法的典型用法代码示例。如果您正苦于以下问题:Python Template.togo_mpegts方法的具体用法?Python Template.togo_mpegts怎么用?Python Template.togo_mpegts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cheetah.Template.Template
的用法示例。
在下文中一共展示了Template.togo_mpegts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NPL
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import togo_mpegts [as 别名]
#.........这里部分代码省略.........
try:
logger.debug("NPL.theurl: %s", theurl)
with tivo_open(theurl) as page:
tivo_cache[theurl] = {'thepage': minidom.parse(page),
'thepage_time': time.time()}
except IOError as e:
handler.redir(UNABLE % (tivoIP, html.escape(str(e))), 10)
return
xmldoc = tivo_cache[theurl]['thepage']
items = xmldoc.getElementsByTagName('Item')
TotalItems = tag_data(xmldoc, 'TiVoContainer/Details/TotalItems')
ItemStart = tag_data(xmldoc, 'TiVoContainer/ItemStart')
ItemCount = tag_data(xmldoc, 'TiVoContainer/ItemCount')
title = tag_data(xmldoc, 'TiVoContainer/Details/Title')
if items:
FirstAnchor = tag_data(items[0], 'Links/Content/Url')
data = []
for item in items:
entry = {}
for tag in ('CopyProtected', 'ContentType'):
value = tag_data(item, 'Details/' + tag)
if value:
entry[tag] = value
if entry['ContentType'].startswith('x-tivo-container'):
entry['Url'] = tag_data(item, 'Links/Content/Url')
entry['Title'] = tag_data(item, 'Details/Title')
entry['TotalItems'] = tag_data(item, 'Details/TotalItems')
lc = tag_data(item, 'Details/LastCaptureDate')
if not lc:
lc = tag_data(item, 'Details/LastChangeDate')
entry['LastChangeDate'] = time.strftime('%b %d, %Y',
time.localtime(int(lc, 16)))
else:
keys = {'Icon': 'Links/CustomIcon/Url',
'Url': 'Links/Content/Url',
'Details': 'Links/TiVoVideoDetails/Url',
'SourceSize': 'Details/SourceSize',
'Duration': 'Details/Duration',
'CaptureDate': 'Details/CaptureDate'}
for key in keys:
value = tag_data(item, keys[key])
if value:
entry[key] = value
if 'SourceSize' in entry:
rawsize = entry['SourceSize']
entry['SourceSize'] = metadata.human_size(rawsize)
if 'Duration' in entry:
dur = getint(entry['Duration']) // 1000
entry['Duration'] = ('%d:%02d:%02d' %
(dur // 3600, (dur % 3600) // 60, dur % 60))
if 'CaptureDate' in entry:
entry['CaptureDate'] = time.strftime('%b %d, %Y',
time.localtime(int(entry['CaptureDate'], 16)))
dnld_url = entry['Url']
# the tivo download url seems to always be absolute, so is this necessary?
# I'm commenting it out -mjl 7/23/2017
#dnld_url = urljoin(baseurl, dnld_url)
if not dnld_url in showinfo:
showinfo[dnld_url] = ShowInfo()
showinfo[dnld_url].from_tivo_container_item(item)
entry.update(showinfo[dnld_url].get_old_basicmeta())
data.append(entry)
else:
data = []
tivoIP = ''
TotalItems = 0
ItemStart = 0
ItemCount = 0
title = ''
tsn = ''
tivo_name = ''
t = Template(NPL_TEMPLATE)
t.quote = quote
t.folder = folder
t.urlstatus = ToGo.get_urlstatus(tivoIP)
t.has_tivodecode = has_tivodecode
t.has_tivolibre = has_tivolibre
t.togo_mpegts = config.is_ts_capable(tsn)
t.tname = tivo_name
t.tivoIP = tivoIP
t.container = handler.cname
t.data = data
t.len = len
t.TotalItems = getint(TotalItems)
t.ItemStart = getint(ItemStart)
t.ItemCount = getint(ItemCount)
t.FirstAnchor = quote(FirstAnchor)
t.shows_per_page = shows_per_page
t.title = title
handler.send_html(str(t), refresh='300')
示例2: Template
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import togo_mpegts [as 别名]
data = []
tivoIP = ''
TotalItems = 0
ItemStart = 0
ItemCount = 0
title = ''
t = Template(NPL_TEMPLATE, filter=EncodeUnicode)
t.escape = escape
t.quote = quote
t.folder = folder
t.status = status
if tivoIP in queue:
t.queue = queue[tivoIP]
t.has_tivodecode = has_tivodecode
t.togo_mpegts = config.is_ts_capable(tsn)
t.tname = tivo_name
t.tivoIP = tivoIP
t.container = handler.cname
t.data = data
t.len = len
t.TotalItems = getint(TotalItems)
t.ItemStart = getint(ItemStart)
t.ItemCount = getint(ItemCount)
t.FirstAnchor = quote(FirstAnchor)
t.shows_per_page = shows_per_page
t.title = title
handler.send_html(str(t), refresh='300')
def get_tivo_file(self, tivoIP, url, mak, togo_path):
# global status
示例3: Template
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import togo_mpegts [as 别名]
ItemStart = 0
ItemCount = 0
FirstAnchor = ''
if useragent.lower().find('mobile') > 0:
t = Template(CONTAINER_TEMPLATE_MOBILE, filter=EncodeUnicode)
else:
t = Template(CONTAINER_TEMPLATE, filter=EncodeUnicode)
t.escape = escape
t.quote = quote
t.folder = folder
t.status = status
if tivoIP in queue:
t.queue = queue[tivoIP]
t.has_tivodecode = has_tivodecode
t.togo_mpegts = togo_mpegts
t.tname = tivo_name
t.tivoIP = tivoIP
t.container = handler.cname
t.data = data
t.len = len
t.TotalItems = int(TotalItems)
t.ItemStart = int(ItemStart)
t.ItemCount = int(ItemCount)
t.FirstAnchor = quote(FirstAnchor)
t.shows_per_page = shows_per_page
handler.send_html(str(t), refresh='300')
def get_tivo_file(self, tivoIP, url, mak, togo_path):
# global status
status[url].update({'running': True, 'queued': False})