本文整理汇总了Python中svtplay_dl.utils.filenamify函数的典型用法代码示例。如果您正苦于以下问题:Python filenamify函数的具体用法?Python filenamify怎么用?Python filenamify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filenamify函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_one_media
def get_one_media(stream, options):
if not options.output or os.path.isdir(options.output):
data = stream.get_urldata()
match = re.search(r"(?i)<title[^>]*>\s*(.*?)\s*</title>", data, re.S)
if match:
options.output_auto = True
title_tag = decode_html_entities(match.group(1))
if not options.output:
options.output = filenamify(title_tag)
else:
# output is a directory
options.output = os.path.join(options.output, filenamify(title_tag))
if platform.system() == "Windows":
# ugly hack. replace \ with / or add extra \ because c:\test\kalle.flv will add c:_tab_est\kalle.flv
if options.output.find("\\") > 0:
options.output = options.output.replace("\\", "/")
videos = []
subs = []
streams = stream.get(options)
if streams:
for i in streams:
if isinstance(i, VideoRetriever):
if options.preferred:
if options.preferred == i.name():
videos.append(i)
else:
videos.append(i)
if isinstance(i, subtitle):
subs.append(i)
if options.subtitle and options.output != "-":
if subs:
subs[0].download(copy.copy(options))
if options.force_subtitle:
return
if len(videos) > 0:
stream = select_quality(options, videos)
try:
stream.download()
except UIException as e:
if options.verbose:
raise e
log.error(e.message)
sys.exit(2)
if options.thumbnail:
if hasattr(stream, "get_thumbnail"):
log.info("thumb requested")
if options.output != "-":
log.info("getting thumbnail")
stream.get_thumbnail(options)
else:
log.info("no thumb requested")
else:
log.error("Can't find any streams for that url")
else:
log.error("Can't find any streams for that url")
开发者ID:magnusaberg,项目名称:svtplay-dl,代码行数:60,代码来源:__init__.py
示例2: filename
def filename(options, stream):
if options.output:
if is_py2:
if platform.system() == "Windows":
options.output = options.output.decode("latin1")
else:
options.output = options.output.decode("utf-8")
options.output = options.output.replace('"', '').replace("'", "").rstrip('\\')
if not options.output or os.path.isdir(options.output):
error, data = stream.get_urldata()
if error:
log.error("Cant find that page")
return False
if data is None:
return False
match = re.search(r"(?i)<title[^>]*>\s*(.*?)\s*</title>", data, re.S)
if match:
options.output_auto = True
title_tag = decode_html_entities(match.group(1))
if not options.output:
options.output = filenamify(title_tag)
else:
# output is a directory
options.output = os.path.join(options.output, filenamify(title_tag))
if platform.system() == "Windows":
# ugly hack. replace \ with / or add extra \ because c:\test\kalle.flv will add c:_tab_est\kalle.flv
if options.output and options.output.find("\\") > 0:
options.output = options.output.replace("\\", "/")
return True
开发者ID:dapstr,项目名称:svtplay-dl,代码行数:30,代码来源:output.py
示例3: _autoname
def _autoname(self, jsondata):
show = jsondata["data"][0]["video_metadata_show"]
season = jsondata["data"][0]["season"]
episode = jsondata["data"][0]["episode"]
title = jsondata["data"][0]["title"]
if is_py2:
show = filenamify(show).encode("latin1")
title = filenamify(title).encode("latin1")
else:
show = filenamify(show)
title = filenamify(title)
return filenamify("{0}.s{1:02d}e{2:02d}.{3}".format(show, int(season), int(episode), title))
开发者ID:andreaskristensson,项目名称:svtplay-dl,代码行数:12,代码来源:dplay.py
示例4: _autoname
def _autoname(self, jsondata):
match = re.search('^([^/]+)/', jsondata["data"]["attributes"]["path"])
show = match.group(1)
season = jsondata["data"]["attributes"]["seasonNumber"]
episode = jsondata["data"]["attributes"]["episodeNumber"]
name = jsondata["data"]["attributes"]["name"]
if is_py2:
show = filenamify(show).encode("latin1")
name = filenamify(name).encode("latin1")
else:
show = filenamify(show)
return filenamify("{0}.s{1:02d}e{2:02d}.{3}".format(show, int(season), int(episode), name))
开发者ID:olof,项目名称:svtplay-dl,代码行数:13,代码来源:dplay.py
示例5: outputfilename
def outputfilename(self, data, filename, raw):
directory = os.path.dirname(filename)
if is_py2:
id = hashlib.sha256(data["programVersionId"]).hexdigest()[:7]
else:
id = hashlib.sha256(data["programVersionId"].encode("utf-8")).hexdigest()[:7]
datatitle = re.search('data-title="([^"]+)"', self.get_urldata())
if not datatitle:
return None
datat = decode_html_entities(datatitle.group(1))
name = self.name(datat)
episode = self.seasoninfo(datat)
if is_py2:
name = name.encode("utf8")
if episode:
title = "{0}.{1}-{2}-svtplay".format(name, episode, id)
else:
title = "{0}-{1}-svtplay".format(name, id)
title = filenamify(title)
if len(directory):
output = os.path.join(directory, title)
else:
output = title
return output
开发者ID:magic75,项目名称:svtplay-dl,代码行数:25,代码来源:oppetarkiv.py
示例6: get
def get(self, options):
match = re.search(r'data-videoid="([^"]+)"', self.get_urldata())
if not match:
parse = urlparse(self.url)
match = re.search(r'video/(\d+)/', parse.fragment)
if not match:
log.error("Can't find video id")
sys.exit(2)
videoid = match.group(1)
data = get_http_data("http://svp.vg.no/svp/api/v1/vgtv/assets/%s?appName=vgtv-website" % videoid)
jsondata = json.loads(data)
if options.output_auto:
directory = os.path.dirname(options.output)
title = "%s" % jsondata["title"]
title = filenamify(title)
if len(directory):
options.output = "%s/%s" % (directory, title)
else:
options.output = title
if "hds" in jsondata["streamUrls"]:
parse = urlparse(jsondata["streamUrls"]["hds"])
manifest = "%s://%s%s?%s&hdcore=3.3.0" % (parse.scheme, parse.netloc, parse.path, parse.query)
streams = hdsparse(copy.copy(options), manifest)
if streams:
for n in list(streams.keys()):
yield streams[n]
if "hls" in jsondata["streamUrls"]:
streams = hlsparse(jsondata["streamUrls"]["hls"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
if "mp4" in jsondata["streamUrls"]:
yield HTTP(copy.copy(options), jsondata["streamUrls"]["mp4"])
开发者ID:TetragrammatonHermit,项目名称:svtplay-dl,代码行数:33,代码来源:vg.py
示例7: _get_static_video
def _get_static_video(self, options, videoid):
access = self._get_access_token(videoid)
if options.output_auto:
data = self.http.request("get", "https://api.twitch.tv/kraken/videos/v%s" % videoid)
if data.status_code == 404:
yield ServiceError("Can't find the video")
return
info = json.loads(data.text)
name = "twitch-%s-%s" % (info["channel"]["name"], filenamify(info["title"]))
directory = os.path.dirname(options.output)
if os.path.isdir(directory):
name = os.path.join(directory, name)
options.output = name
if "token" not in access:
raise TwitchUrlException('video', self.url)
nauth = quote_plus(str(access["token"]))
authsig = access["sig"]
url = "http://usher.twitch.tv/vod/%s?nauth=%s&nauthsig=%s" % (
videoid, nauth, authsig)
streams = hlsparse(options, self.http.request("get", url), url)
if streams:
for n in list(streams.keys()):
yield streams[n]
开发者ID:gusseleet,项目名称:svtplay-dl,代码行数:27,代码来源:twitch.py
示例8: _autoname
def _autoname(self, dataj):
program = dataj["format_slug"]
season = None
episode = None
title = None
if "season" in dataj["format_position"]:
if dataj["format_position"]["season"] > 0:
season = dataj["format_position"]["season"]
if season:
if len(dataj["format_position"]["episode"]) > 0:
episode = dataj["format_position"]["episode"]
try:
episode = int(episode)
except ValueError:
title = filenamify(episode)
episode = None
if dataj["type"] == "clip":
#Removes the show name from the end of the filename
#e.g. Showname.S0X.title instead of Showname.S07.title-showname
match = re.search(r'(.+)-', dataj["title"])
if match:
title = filenamify(match.group(1))
else:
title = filenamify(dataj["title"])
if "derived_from_id" in dataj:
if dataj["derived_from_id"]:
parent_id = dataj["derived_from_id"]
parent_episode = self.http.request("get", "http://playapi.mtgx.tv/v3/videos/{0}".format(parent_id))
if parent_episode.status_code != 403: #if not geoblocked
datajparent = json.loads(parent_episode.text)
if not season and datajparent["format_position"]["season"] > 0:
season = datajparent["format_position"]["season"]
if len(datajparent["format_position"]["episode"]) > 0:
episode = datajparent["format_position"]["episode"]
name = filenamify(program)
if season:
name = "{0}.s{1:02d}".format(name, int(season))
if episode:
name = "{0}e{1:02d}".format(name, int(episode))
if title:
name = "{0}.{1}".format(name, title)
return name
开发者ID:magic75,项目名称:svtplay-dl,代码行数:46,代码来源:viaplay.py
示例9: _autoname
def _autoname(self, jsondata):
show = jsondata["data"][0]["video_metadata_show"]
season = jsondata["data"][0]["season"]
episode = jsondata["data"][0]["episode"]
title = jsondata["data"][0]["title"]
if is_py2:
show = show.encode("latin1")
title = title.encode("latin1")
return filenamify("{}.s{:02d}e{:02d}.{}".format(show, int(season), int(episode), title))
开发者ID:spaam,项目名称:svtplay-dl,代码行数:9,代码来源:dplay.py
示例10: outputfilename
def outputfilename(self, data, filename):
if filename:
directory = os.path.dirname(filename)
else:
directory = ""
name = None
if "programTitle" in data and data["programTitle"]:
name = filenamify(data["programTitle"])
elif "titleSlug" in data and data["titleSlug"]:
name = filenamify(data["titleSlug"])
other = filenamify(data["title"])
if "programVersionId" in data:
vid = str(data["programVersionId"])
else:
vid = str(data["id"])
if is_py2:
id = hashlib.sha256(vid).hexdigest()[:7]
else:
id = hashlib.sha256(vid.encode("utf-8")).hexdigest()[:7]
if name == other:
other = None
elif name is None:
name = other
other = None
season = self.seasoninfo(data)
title = name
if season:
title += ".{}".format(season)
if other:
title += ".{}".format(other)
if "accessService" in data:
if data["accessService"] == "audioDescription":
title += "-syntolkat"
if data["accessService"] == "signInterpretation":
title += "-teckentolkat"
title += "-{}-{}".format(id, self.__class__.__name__.lower())
title = filenamify(title)
if len(directory):
output = os.path.join(directory, title)
else:
output = title
return output
开发者ID:olof,项目名称:svtplay-dl,代码行数:44,代码来源:svtplay.py
示例11: get
def get(self, options):
parse = urlparse(self.url)
if parse.hostname == "video.disney.se":
match = re.search(r"Grill.burger=({.*}):", self.get_urldata())
if not match:
log.error("Can't find video info")
return
jsondata = json.loads(match.group(1))
for n in jsondata["stack"]:
if len(n["data"]) > 0:
for x in n["data"]:
if "flavors" in x:
for i in x["flavors"]:
if i["format"] == "mp4":
yield HTTP(copy.copy(options), i["url"], i["bitrate"])
else:
match = re.search(r"uniqueId : '([^']+)'", self.get_urldata())
if not match:
log.error("Can't find video info")
return
uniq = match.group(1)
match = re.search("entryId : '([^']+)'", self.get_urldata())
entryid = match.group(1)
match = re.search("partnerId : '([^']+)'", self.get_urldata())
partnerid = match.group(1)
match = re.search("uiConfId : '([^']+)'", self.get_urldata())
uiconfid = match.group(1)
url = "http://cdnapi.kaltura.com/html5/html5lib/v1.9.7.6/mwEmbedFrame.php?&wid=%s&uiconf_id=%s&entry_id=%s&playerId=%s&forceMobileHTML5=true&urid=1.9.7.6&callback=mwi" % \
(partnerid, uiconfid, entryid, uniq)
data = get_http_data(url)
match = re.search(r"mwi\(({.*})\);", data)
jsondata = json.loads(match.group(1))
data = jsondata["content"]
match = re.search(r"window.kalturaIframePackageData = ({.*});", data)
jsondata = json.loads(match.group(1))
ks = jsondata["enviornmentConfig"]["ks"]
if options.output_auto:
name = jsondata["entryResult"]["meta"]["name"]
directory = os.path.dirname(options.output)
options.service = "disney"
title = "%s-%s" % (name, options.service)
title = filenamify(title)
if len(directory):
options.output = "%s/%s" % (directory, title)
else:
options.output = title
url = "http://cdnapi.kaltura.com/p/%s/sp/%s00/playManifest/entryId/%s/format/applehttp/protocol/http/a.m3u8?ks=%s&referrer=aHR0cDovL3d3dy5kaXNuZXkuc2U=&" % (partnerid[1:], partnerid[1:], entryid, ks)
redirect = check_redirect(url)
streams = hlsparse(redirect)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
开发者ID:julveson,项目名称:svtplay-dl,代码行数:54,代码来源:disney.py
示例12: outputfilename
def outputfilename(self, data, filename):
if filename:
directory = os.path.dirname(filename)
else:
directory = ""
name = None
if data["programTitle"]:
name = filenamify(data["programTitle"])
other = filenamify(data["title"])
if "programVersionId" in data:
vid = str(data["programVersionId"])
else:
vid = str(data["id"])
if is_py2:
id = hashlib.sha256(vid).hexdigest()[:7]
else:
id = hashlib.sha256(vid.encode("utf-8")).hexdigest()[:7]
if name == other:
other = None
elif name is None:
name = other
other = None
season = self.seasoninfo(data)
title = name
if season:
title += ".%s" % season
if other:
title += ".%s" % other
if data["accessServices"]["audioDescription"]:
title += "-syntolkat"
if data["accessServices"]["signInterpretation"]:
title += "-teckentolkat"
title += "-%s-svtplay" % id
title = filenamify(title)
if len(directory):
output = os.path.join(directory, title)
else:
output = title
return output
开发者ID:qnorsten,项目名称:svtplay-dl,代码行数:41,代码来源:svtplay.py
示例13: outputfilename
def outputfilename(data, filename, raw):
directory = os.path.dirname(filename)
name = data["statistics"]["folderStructure"]
if name.find(".") > 0:
name = name[:name.find(".")]
match = re.search("^arkiv-", name)
if match:
name = name.replace("arkiv-", "")
name = name.replace("-", ".")
season = seasoninfo(raw)
other = filenamify(data["context"]["title"])
if season:
title = "%s.%s.%s-%s-svtplay" % (name, season, other, data["videoId"])
else:
title = "%s.%s-%s-svtplay" % (name, other, data["videoId"])
title = filenamify(title)
if len(directory):
output = os.path.join(directory, title)
else:
output = title
return output
开发者ID:Fredro,项目名称:svtplay-dl,代码行数:21,代码来源:svtplay.py
示例14: _get_static_video
def _get_static_video(self, options, videoid):
access = self._get_access_token(videoid)
if options.output_auto:
info = json.loads(get_http_data("https://api.twitch.tv/kraken/videos/v%s" % videoid)[1])
if info["description"]:
options.output = "twitch-%s-%s_%s" % (info["channel"]["name"], filenamify(info["title"]), filenamify(info["description"]))
else:
options.output = "twitch-%s-%s" % (info["channel"]["name"], filenamify(info["title"]))
if "token" not in access:
raise JustinUrlException('video', self.url)
nauth = quote_plus(str(access["token"]))
authsig = access["sig"]
url = "http://usher.twitch.tv/vod/%s?nauth=%s&nauthsig=%s" % (
videoid, nauth, authsig)
streams = hlsparse(url)
if streams:
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
开发者ID:persundstrom,项目名称:svtplay-dl,代码行数:22,代码来源:justin.py
示例15: _autoname
def _autoname(self, dataj):
program = dataj["format_slug"]
season = dataj["format_position"]["season"]
episode = None
if season:
if len(dataj["format_position"]["episode"]) > 0:
episode = dataj["format_position"]["episode"]
name = filenamify(program)
if season:
name = "{}.s{:02d}".format(name, int(season))
if episode:
name = "{}e{:02d}".format(name, int(episode))
return name
开发者ID:avtobiff,项目名称:svtplay-dl,代码行数:13,代码来源:viaplay.py
示例16: filename
def filename(stream):
if stream.options.output:
if is_py2:
if platform.system() == "Windows":
stream.options.output = stream.options.output.decode("latin1")
else:
stream.options.output = stream.options.output.decode("utf-8")
if not stream.options.output or os.path.isdir(stream.options.output):
data = ensure_unicode(stream.get_urldata())
if data is None:
return False
match = re.search(r"(?i)<title[^>]*>\s*(.*?)\s*</title>", data, re.S)
if match:
stream.options.output_auto = True
title_tag = decode_html_entities(match.group(1))
if not stream.options.output:
stream.options.output = filenamify(title_tag)
else:
# output is a directory
stream.options.output = os.path.join(stream.options.output, filenamify(title_tag))
return True
开发者ID:chenliang100,项目名称:svtplay-dl,代码行数:22,代码来源:output.py
示例17: _autoname
def _autoname(self, dataj):
program = dataj["format_slug"]
season = dataj["format_position"]["season"]
episode = None
if season:
if len(dataj["format_position"]["episode"]) > 0:
episode = dataj["format_position"]["episode"]
name = filenamify(program)
if season:
name = "%s.s%s" % (name, season)
if episode:
name = "%se%s" % (name, episode)
return name
开发者ID:gusseleet,项目名称:svtplay-dl,代码行数:13,代码来源:viaplay.py
示例18: get
def get(self, options):
error, data = self.get_urldata()
if error:
log.error("Can't get the page")
return
match = re.search(r'data-videoid="([^"]+)"', data)
if not match:
parse = urlparse(self.url)
match = re.search(r'video/(\d+)/', parse.fragment)
if not match:
log.error("Can't find video file for: %s", self.url)
return
videoid = match.group(1)
error, data = get_http_data("http://svp.vg.no/svp/api/v1/vgtv/assets/%s?appName=vgtv-website" % videoid)
if error:
log.error("Cant get video info")
return
jsondata = json.loads(data)
if options.output_auto:
directory = os.path.dirname(options.output)
title = "%s" % jsondata["title"]
title = filenamify(title)
if len(directory):
options.output = "%s/%s" % (directory, title)
else:
options.output = title
if self.exclude(options):
return
if "hds" in jsondata["streamUrls"]:
streams = hdsparse(copy.copy(options), jsondata["streamUrls"]["hds"])
if streams:
for n in list(streams.keys()):
yield streams[n]
if "hls" in jsondata["streamUrls"]:
streams = hlsparse(jsondata["streamUrls"]["hls"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
if "mp4" in jsondata["streamUrls"]:
yield HTTP(copy.copy(options), jsondata["streamUrls"]["mp4"])
开发者ID:dapstr,项目名称:svtplay-dl,代码行数:42,代码来源:vg.py
示例19: get
def get(self):
if self.exclude():
yield ServiceError("Excluding video")
return
parse = urlparse(self.url)
if not parse.path.startswith("/video"):
yield ServiceError("Can't find video info")
return
wanted_id = parse.path[7:]
current_time = int((datetime.utcnow() - datetime.utcfromtimestamp(0)).total_seconds() * 1000)
api_url = "https://www.atgplay.se/api/{0}/video/{1}".format(current_time, wanted_id)
video_assets = self.http.request("get", api_url)
try:
janson = json.loads(video_assets.text)
except json.decoder.JSONDecodeError:
yield ServiceError("Can't decode api request: {0}".format(video_assets.text))
return
if "title" in janson:
directory = os.path.dirname(self.options.output)
title = filenamify(janson["title"])
self.options.output = os.path.join(directory, title)
if "urls" in janson:
for i in janson["urls"]:
stream = None
if "m3u" == i:
stream = hlsparse(self.options, self.http.request("get", janson["urls"]["m3u"]), janson["urls"]["m3u"])
if stream:
for key in list(stream.keys()):
yield stream[key]
开发者ID:olof,项目名称:svtplay-dl,代码行数:38,代码来源:atg.py
示例20: get
def get(self):
data = self.get_urldata()
parse = urlparse(self.url)
match = re.search(r'^/([a-z]{2})/', parse.path)
if not match:
yield ServiceError("Cant county code")
return
res = self.http.get("http://www.pokemon.com/api/pokemontv/channels?region={0}".format(match.group(1)))
janson = res.json()
match = re.search('data-video-season="([0-9]+)"', data)
season = match.group(1)
match = re.search('data-video-episode="([0-9]+)"', data)
episode = match.group(1)
for i in janson:
for n in i["media"]:
if season == n["season"] and episode == n["episode"]:
stream = n["stream_url"]
if self.options.output_auto:
directory = os.path.dirname(self.options.output)
basename = os.path.basename(self.options.output)
title = "pokemon.s{0}e{1}-{2}".format(season, episode, basename)
title = filenamify(title)
if len(directory):
self.options.output = os.path.join(directory, title)
else:
self.options.output = title
if self.exclude():
yield ServiceError("Excluding video")
return
streams = hlsparse(self.options, self.http.request("get", stream), stream)
for n in list(streams.keys()):
yield streams[n]
开发者ID:magic75,项目名称:svtplay-dl,代码行数:38,代码来源:pokemon.py
注:本文中的svtplay_dl.utils.filenamify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论