本文整理汇总了Python中asi.Utils类的典型用法代码示例。如果您正苦于以下问题:Python Utils类的具体用法?Python Utils怎么用?Python Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, pid, grabber, data):
super(Elem, self).__init__()
self.pid = pid
self.title = data.findtext("titolo")
self.description = data.findtext("descrizione")
self.channel = data.findtext("dominio")
self.grabber = grabber
strTime = data.findtext("datapubblicazione")
strTime = strTime.replace("-", "/")
self.datetime = datetime.datetime.strptime(strTime, "%d/%m/%Y")
# extra experimental data
h264 = data.findtext("h264")
Utils.addH264Url(self.h264, 0, h264)
self.ts = data.findtext("m3u8")
self.id = data.findtext("localid")
self.length = data.findtext("durata")
web = data.findtext("web")
if not web:
web = RAIUrls.getWebFromID(self.id)
self.url = RAIUrls.base + web
self.filename = Utils.makeFilename(self.title)
self.canFollow = True
示例2: __init__
def __init__(self, grabber, url, channel, date, pid, title, desc, h264, m3u8, wmv):
super(Program, self).__init__()
self.url = url
self.pid = pid
self.title = title
self.description = desc
self.channel = channel
if date:
self.datetime = datetime.datetime.strptime(date, "%d/%m/%Y")
else:
self.datetime = datetime.datetime.now()
Utils.addH264Url(self.h264, 0, h264)
if m3u8:
self.ts = m3u8
if wmv:
self.mms = wmv
self.grabber = grabber
self.filename = Utils.makeFilename(self.title)
self.canFollow = True
示例3: display
def display(self, width):
print("=" * width)
print("PID:", self.pid)
print("Channel:", self.channel)
print("Title:", self.title)
if self.description:
print("Description:", self.description)
if self.datetime:
print("Date:", Utils.strDate(self.datetime))
if self.length:
print("Length:", self.length)
if self.filename:
print("Filename:", self.filename)
print()
if self.canFollow:
print("Follow: ENABLED")
print()
m3 = self.getTabletPlaylist()
Utils.displayH264(self.getH264())
if self.getTS() or self.mms:
if self.getTS():
print("ts:", self.getTS())
if self.mms:
print("mms:", self.mms)
print()
Utils.displayM3U8(m3)
示例4: process
def process(grabber, f, db):
o = json.load(f)
for v in o:
pid = Utils.getNewPID(db, None)
p = Group(grabber, pid, v["title"], v["linkDemand"], v["date"], v["editore"])
Utils.addToDB(db, p)
示例5: download
def download(db, grabber, downType):
progress = Utils.getProgress()
name = Utils.httpFilename(RAIUrls.info)
folder = Config.tgFolder
localName = os.path.join(folder, name)
f = Utils.download(grabber, progress, RAIUrls.info, localName, downType, "utf-8", True)
process(grabber, progress, downType, f, db)
示例6: processItem
def processItem(grabber, progress, downType, title, time, url, db):
folder = Config.tgFolder
name = Utils.httpFilename(url)
localName = os.path.join(folder, name)
f = Utils.download(grabber, progress, url, localName, downType, "utf-8", True)
if f:
processSet(grabber, title, time, f, db)
示例7: download
def download(db, grabber, downType):
page = Utils.httpFilename(RAIUrls.junior)
folder = Config.juniorFolder
localFilename = os.path.join(folder, page)
progress = Utils.getProgress()
f = Utils.download(grabber, progress, RAIUrls.junior, localFilename, downType, None, True)
process(grabber, progress, folder, f, db, downType)
示例8: getH264
def getH264(self):
if self.h264:
return self.h264
content = Utils.getStringFromUrl(self.grabber, self.url)
root = ElementTree.fromstring(content)
if root.tag == "smil":
url = root.find("body").find("switch").find("video").attrib.get("src")
Utils.addH264Url(self.h264, 0, url)
return self.h264
示例9: extractH264Ext
def extractH264Ext(value):
res = {}
reg = "^h264_(\d+)"
for k in value:
m = re.match(reg, k)
url = value[k]
if m and url:
bwidth = int(m.group(1))
Utils.addH264Url(res, bwidth, url)
return res
示例10: download
def download(db, grabber, downType):
page = Utils.httpFilename(RAIUrls.onDemand)
folder = Config.demandFolder
localFilename = os.path.join(folder, page)
progress = Utils.getProgress()
f = Utils.download(grabber, progress, RAIUrls.onDemand, localFilename, downType, "raw-unicode-escape", True)
process(grabber, f, db)
示例11: download
def download(db, grabber, downType):
progress = Utils.getProgress()
for channel in channels:
url = getCatalogueUrl(channel)
name = Utils.httpFilename(url) + "." + channel
folder = Config.m6Folder
localName = os.path.join(folder, name)
f = Utils.download(grabber, progress, url, localName, downType, "utf-8", True)
if (f):
process(grabber, downType, f, channel, db)
示例12: download
def download(db, grabber, downType):
progress = Utils.getProgress()
folder = Config.tf1Folder
localName = os.path.join(folder, "news.json")
f = Utils.download(grabber, progress, newsUrl, localName, downType, "utf-8", True)
processNews(grabber, f, folder, progress, downType, db)
localName = os.path.join(folder, "programs.json")
f = Utils.download(grabber, progress, programsUrl, localName, downType, "utf-8", True)
processPrograms(grabber, f, folder, progress, downType, db)
示例13: processPage
def processPage(grabber, progress, folder, f, db, downType):
root = ElementTree.parse(f).getroot().find('menu')
for e in root:
if e.tag == "item" and e.attrib.get("id") == "video":
path = e.find("src").attrib.get("path")
url = RAIUrls.getJuniorBlock(path)
name = Utils.httpFilename(url)
localFilename = os.path.join(folder, name)
g = Utils.download(grabber, progress, url, localFilename, downType, None, True)
if g:
processBlock(grabber, progress, folder, g, db, downType)
示例14: __init__
def __init__(self, grabber, url, downType, pid):
super(Demand, self).__init__()
self.grabber = grabber
parts = urllib.parse.urlparse(url)
if not parts.scheme:
url = RAIUrls.getItemUrl(url)
self.url = url
self.pid = pid
folder = Config.itemFolder
localFilename = os.path.join(folder, Utils.httpFilename(self.url))
f = Utils.download(grabber, None, self.url, localFilename, downType, "utf-8")
parser = VideoHTMLParser()
parser.feed(f.read())
self.values = parser.values
self.channel = "item"
self.title = self.values.title
self.ts = self.values.videoUrlM3U8
Utils.addH264Url(self.h264, 0, self.values.videoUrlH264)
if self.values.date:
self.datetime = datetime.datetime.strptime(self.values.date, "%d/%m/%Y")
self.mms = None
if self.values.type and self.values.type != "Video":
# this is a case of a Photogallery
self.url = None
self.filename = None
return
if not self.values.videoUrl:
self.values.videoUrl = self.values.videoPath
#sometimes we get .mp4 which does not work
self.values.videoUrl = self.values.videoUrl.replace("relinkerServlet.mp4", "relinkerServlet.htm")
#make a nice filename
self.filename = Utils.makeFilename(self.title)
self.mms = self.values.videoUrl
示例15: parseItem
def parseItem(grabber, prog, db):
pid = prog["id_diffusion"]
date = prog["date"]
hour = prog["heure"]
url = baseUrl + prog["url_video"]
desc = prog["accroche"]
channel = prog["chaine"]
name = prog["titre"]
minutes = prog["duree"]
length = datetime.timedelta(minutes = int(minutes))
pid = Utils.getNewPID(db, pid)
p = Program(grabber, channel, date, hour, pid, length, name, desc, url)
Utils.addToDB(db, p)