本文整理汇总了Python中transcode.supported_format函数的典型用法代码示例。如果您正苦于以下问题:Python supported_format函数的具体用法?Python supported_format怎么用?Python supported_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了supported_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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
示例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
示例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
示例11: pre_cache
def pre_cache(self, full_path):
if Video.video_file_filter(self, full_path):
transcode.supported_format(full_path)
示例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
#.........这里部分代码省略.........
示例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)
示例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))
示例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))