本文整理汇总了Python中resources.lib.utils.downloadCatalog函数的典型用法代码示例。如果您正苦于以下问题:Python downloadCatalog函数的具体用法?Python downloadCatalog怎么用?Python downloadCatalog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了downloadCatalog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_shows
def list_shows(channel,folder):
shows=[]
if folder=='none' :
shows.append( [channel,'ba', 'Bandes Annonces'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158003', 'Parodies'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158004', 'Emissions dActu'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158005', 'Emissions Bonus'.encode('utf-8') , '','folder'] )
else:
if folder=='ba':
shows.append( [channel,'/bandes-annonces/', 'A ne pas manquer'.encode('utf-8') , '','folder'] )
shows.append( [channel,'/bandes-annonces/plus-recentes/', 'Les plus recentes'.encode('utf-8') , '','folder'] )
shows.append( [channel,'/bandes-annonces/prochainement/', 'Bientot au cinema'.encode('utf-8') , '','folder'] )
elif folder.find('/')==-1 or folder.find('bandes-annonces')!=-1:
if folder.find('bandes-annonces')!=-1:
filePath=utils.downloadCatalog('http://www.allocine.fr/video%s' % (folder),'allocine%s1.html' % (folder),False)
else:
filePath=utils.downloadCatalog('http://www.allocine.fr/video/prgcat-%s/' % (folder),'allocine%s1.html' % (folder),False)
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '')
nbPages=1
pages=re.findall('<li><a href="(.*?)">(.*?)</a></li>', html)
if pages:
nbPages=len(pages)+1
for i in range(1, nbPages+1):
if folder.find('bandes-annonces')!=-1:
filePath=utils.downloadCatalog('http://www.allocine.fr/video%s?page=%s' % (folder,i),'allocine%s%s.html' % (folder,i),False)
else:
filePath=utils.downloadCatalog('http://www.allocine.fr/video/prgcat-%s/?page=%s' % (folder,i),'allocine%s%s.html' % (folder,i),False)
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '')
images=re.findall('<div class="pos_rel thumbs.*?" > <span class="(.*?)"> <img(.*?)src=\'(.*?)\' /> </span> </div>', html)
items=re.findall('<h. class="title "> <a href="(.*?)">(.*?)</a> </h.>', html)
j=0
image=''
for item in items:
if images[j][1]!=' ':
image= images[j][1].replace(' data-attr=\'{"src":"','').replace('"}\'','')
else:
image=images[j][2]
if folder.find('bandes-annonces')!=-1:
videoId=re.findall('player_gen_cmedia=(.*?)&cfilm',item[0])[0]
infoLabels={ "Title": formatTitle(item[1])}
shows.append( [channel, videoId, formatTitle(item[1]), image,'play'] )
else:
shows.append( [channel,item[0], formatTitle(item[1]) ,image ,'folder'] )
j=j+1
else:
filePath=utils.downloadCatalog('http://www.allocine.fr%s' % (folder),'allocine%s.html' % (folder),False)
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '')
seasons=re.findall('<a class="button btn-primary btn-large" href="(.*?)">(.*?)</a>', html)
for season in seasons:
shows.append( [channel,season[0], formatTitle(season[1]) ,'' ,'shows'] )
return shows
示例2: list_shows
def list_shows(channel,folder):
shows=[]
filePath=utils.downloadCatalog('http://www.nrj-play.fr/%s/replay' % channel,channel + '.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace("\n", "")
html=' '.join(html.split())
if folder=='none':
match = re.compile(r'<li class="subNav-menu-item">(.*?)<a href="(.*?)" class=(.*?)>(.*?)</a>',re.DOTALL).findall(html)
if match:
for empty,link,empty2,title in match:
if 'active' not in empty2:
shows.append( [channel,link, title , '','folder'] )
else:
print 'http://www.nrj-play.fr%s' % (folder)
filePath=utils.downloadCatalog('http://www.nrj-play.fr%s' % (folder),channel + folder +'.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace("\n", "")
html=' '.join(html.split())
print html
match = re.compile(r'<h2 class="linkProgram-title">(.*?)</h2>(.*?)<a href="(.*?)" class="linkProgram-more"(.*?)<img src="(.*?)" class="program-img"',re.DOTALL).findall(html)
if match:
for title,empty1,link,empty2,img in match:
title = common.replaceHTMLCodes(title)
title = title.title()
shows.append( [channel,link, title.encode("utf-8") , img,'shows'] )
return shows
示例3: list_shows
def list_shows(channel,folder):
shows = []
uniqueItem = dict()
if folder=='none':
filePath = utils.downloadCatalog(urlCatalog ,'rts.json',False,{})
filPrgm = open(filePath).read()
jsonParser = json.loads(filPrgm)
topics = jsonParser['Topics']['Topic']
for topic in topics :
shows.append( [channel,topic['id'], topic['title'].encode('utf-8'),'','folder'] )
else:
filePath = utils.downloadCatalog(showsList % folder ,'rts%s.json' % folder,False,{})
filPrgm = open(filePath).read()
jsonParser = json.loads(filPrgm)
videos = jsonParser['Videos']['Video']
for video in videos :
print video
idSet=video['AssetSet']['Show']['id']
if idSet not in uniqueItem:
uniqueItem[idSet]=idSet
imgURL=video['AssetSet']['Show']['Image']['ImageRepresentations']['ImageRepresentation'][0]['url']+imgFormat
shows.append( [channel,folder + '-' + idSet, video['AssetSet']['title'].encode('utf-8'),imgURL.encode('utf-8'),'shows'] )
return shows
示例4: list_shows
def list_shows(channel,folder):
shows=[]
filePath=utils.downloadCatalog('http://www.nrj-play.fr/%s/replay' % channel,channel + '.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a')
if folder=='none':
match = re.compile(r'<li class="subNav-menu-item">(.*?)<a href="(.*?)" class=(.*?)>(.*?)</a>',re.DOTALL).findall(html)
if match:
for empty,link,empty2,title in match:
if 'active' not in empty2:
shows.append( [channel,link, title , '','folder'] )
else:
print 'http://www.nrj-play.fr%s' % (folder)
filePath=utils.downloadCatalog('http://www.nrj-play.fr%s' % (folder),channel + folder +'.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace("\n", "")
match = re.compile(r'<div class="linkProgram-infos">(.*?)<a href="(.*?)" class="linkProgram-thumbnail embed-responsive embed-responsive-16by9">(.*?)<img src="(.*?)" class="program-img embed-responsive-item" alt="(.*?)"',re.DOTALL).findall(html)
if match:
for empty,link,empty2,img,title in match:
shows.append( [channel,link, title.encode("utf-8") , img,'shows'] )
return shows
示例5: list_shows
def list_shows(channel,folder):
shows=[]
if folder=='none' :
shows.append( [channel,'ba', 'Bandes Annonces'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158001|1', 'Webseries'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158002|1', 'Mangas'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158003|1', 'Parodies'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158004|1', 'Emissions dActu'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158005|1', 'Emissions Bonus'.encode('utf-8') , '','folder'] )
shows.append( [channel,'158006|1', 'Stars'.encode('utf-8') , '','folder'] )
else:
if folder=='ba':
shows.append( [channel,'video/bandes-annonces/|1', 'A ne pas manquer'.encode('utf-8') , '','shows'] )
shows.append( [channel,'/bandes-annonces/plus-recentes/|1', 'Les plus recentes'.encode('utf-8') , '','shows'] )
shows.append( [channel,'/bandes-annonces/prochainement/|1', 'Bientot au cinema'.encode('utf-8') , '','shows'] )
else:
if 'programme' in folder:
filePath=utils.downloadCatalog('http://www.allocine.fr/' + folder ,'allocine' + folder.replace('\\','') +'.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '')
match = re.compile(r'<a class="button btn-primary btn-large" href="(.*?)">(.*?)</a>',re.DOTALL).findall(html)
for url,title in match:
shows.append( [channel,url + '|1', title.replace("<i class='icon-sign-plus'></i>","") ,'' ,'shows'] )
else:
cat,page=folder.split('|')
filePath=utils.downloadCatalog('http://www.allocine.fr/video/prgcat-' + cat + '/?page=' + page ,'allocine' + cat + '-' + page +'.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '')
match = re.compile(r'btn-primary btn-large (.*?)">(.*?)<i class="icon-arrow-(.*?)"></i>',re.DOTALL).findall(html)
prev=False
next=False
for status,empty,arrow in match:
if arrow=='left':
prev=('disabled' not in status)
if arrow=='right':
next=('disabled' not in status)
if prev:
shows.append( [channel,cat + '|' + str(int(page)-1), '<<Page Precedente' ,'' ,'folder'] )
match = re.compile(r'<h2 class="title "> <span > <a href="(.*?)">(.*?)</a> </span> </h2>',re.DOTALL).findall(html)
for url,title in match:
shows.append( [channel,url, title ,'' ,'folder'] )
if next :
shows.append( [channel,cat + '|' + str(int(page)+1), 'Page Suivante>>' ,'' ,'folder'] )
return shows
示例6: list_videos
def list_videos(channel,params):
videos = []
program_url = params.split('|')[0]
titre_program = params.split('|')[1]
filePath = utils.downloadCatalog(program_url,'becurioustv_'+titre_program+'.html',False,{})
html = open(filePath).read().decode("utf-8")
season_grid = common.parseDOM(html,"div",attrs={"class":"seasons-grid tab-season"})
for season in season_grid:
list_li = common.parseDOM(season,"li")
for li in list_li:
title_h5 = common.parseDOM(li,"h5")
title = common.parseDOM(title_h5,"a")[0].encode('utf-8')
#title = common.replaceHTMLCodes(title)
url_show = common.parseDOM(title_h5,"a", ret="href")[0].encode('utf-8')
url_show = url_root+url_show
url_icon = common.parseDOM(li,"img", ret="src")[0].encode('utf-8')
episode_number = common.parseDOM(li,"div", attrs={"class":"user-info"})
episode_number = common.parseDOM(episode_number, "a")[0].encode('utf-8')
videos.append([channel,url_show+'|'+title,title,url_icon,{'Title':title+" - "+episode_number},'play'])
return videos
示例7: list_shows
def list_shows(channel,folder):
shows = []
filePath = utils.downloadCatalog(url_shows,'becurioustv.html',False,{}) # Page principale du replay
html = open(filePath).read().decode("utf-8")
shows_container = common.parseDOM(html,"div", attrs={"class": "shows-container background-pink"})
if folder == 'none':
for show in shows_container:
title = common.parseDOM(show,"h1", attrs={"class": "color-magenta"})[0].encode('utf-8')
show_icon = common.parseDOM(show,"div", attrs={"class": "shows__icon"})
url_show = common.parseDOM(show_icon,"img", ret="src")[0].encode('utf-8')
url_show = url_root+url_show
shows.append([channel,title,title,url_show,'folder'])
else:
for show in shows_container:
if folder in show.encode('utf-8'):
item_list = common.parseDOM(show,"div", attrs={"class": "item"})
for item in item_list:
title = common.parseDOM(item,"h2")[0].encode('utf-8')
#title = common.replaceHTMLCodes(title)
episodes_length = common.parseDOM(item,"span")[0].encode('utf-8')
url_show = common.parseDOM(item,"a", ret="href")[0].encode('utf-8')
url_show = url_root+url_show
url_icon = common.parseDOM(item,"img", ret="src")[0].encode('utf-8')
url_icon = url_root+url_icon
shows.append([channel,url_show+'|'+title,title+" - "+episodes_length,url_icon,'shows'])
return shows
示例8: list_videos
def list_videos(channel,show_title):
videos=[]
filePath=utils.downloadCatalog('http://webservices.francetelevisions.fr/catchup/flux/flux_main.zip','Pluzz.zip',False)
zf = zipfile.ZipFile(filePath)
data = zf.read('catch_up_' + channel + '.json')
jsoncatalog = json.loads(data)
programmes = jsoncatalog['programmes']
for programme in programmes :
name = programme['titre'].encode("utf-8")
if name == show_title :
desc=''
duration=0
date=''
if programme['date'] :
date = str(programme['date'].split('-')[2])+'-'+str(programme['date'].split('-')[1])+'-'+str(programme['date'].split('-')[0])
if programme['sous_titre'] != "" :
name = name +' : '+programme['sous_titre'].encode("utf-8")
else:
name+=' - ' + date
video_url = url_base_videos+programme['url_video'].encode("utf-8")
image_url = url_base_images+programme['url_image_racine'].encode("utf-8")+'.'+programme['extension_image'].encode("utf-8")
if programme['accroche'] :
desc = programme['accroche'].encode("utf-8")
if programme['duree'] :
duration = programme['duree'].encode("utf-8")
infoLabels={ "Title": name,"Plot":desc,"Aired":date,"Duration": duration, "Year":date[:4]}
videos.append( [channel, video_url, name, image_url,infoLabels,'play'] )
return videos
示例9: getVideoURL
def getVideoURL(channel,video_url):
file_path = utils.downloadCatalog(video_url, video_url, bypass_cache, {})
html = open(file_path).read()
videoId = video_id_re.search(html).group(1)
result = 'plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid='+videoId;
print("RESULT : " + result)
return result;
示例10: list_videos
def list_videos(channel,show):
videos=[]
url_list = show.split('|')[0]
title = show.split('|')[1]
another_page = True
current_page = 1
while another_page == True:
url_page = url_list+'?&page='+str(current_page)
filePath=utils.downloadCatalog(url_page ,channel +'_'+ title +'_'+str(current_page)+'.html',False,{})
html=open(filePath).read()
if 'document.documentSelection.page.value='+str(current_page+1) in html:
current_page += 1
else:
another_page = False
# empty # year #empty1 # duration #empty2 #empty3 #title #empty4 #desc #empty5 #link #empty6
match = re.compile(r'<div class="bloc_gauche_image">(.*?)<img src="(.*?)" border="0"(.*?)Date :</span>(.*?)</div>(.*?)Durée : </span>(.*?):(.*?):(.*?)</div>(.*?)<span(.*?)>(.*?)</span>(.*?)>(.*?)</span>(.*?)<a href="(.*?)" class=(.*?)',re.DOTALL).findall(html)
if match:
for empty0, img, empty, year, empty1, hour, minutes, seconds, empty2, empty3, title, empty4, desc, empty5, link, empty6 in match:
link = url_root+"/"+link
duration = int(hour)*3600 + int(minutes)*60 + int(seconds)
#desc = " ".join(desc.split())
date = "01/01/"+year
infoLabels={ "Title": title, "Plot":desc, "Year":year, "Aired":date}
videos.append( [channel, link, title, img,infoLabels,'play'] )
return videos
示例11: list_videos
def list_videos(channel,param):
folder=param.split('$$')[0]
category=param.split('$$')[1]
videos=[]
filePath=utils.downloadCatalog(urlBase + folder,'gulli' + folder +'.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace("\n", " ")
html=' '.join([segment for segment in html.split()])
uls = common.parseDOM(html,"ul",attrs={"class":"liste_resultats"})
for ul in uls:
replays = common.parseDOM(ul,"li")
for replay in replays :
title = (common.parseDOM(replay,"span",attrs={"class":"tooltip_ctnt"}) [0]).encode("utf-8")
if title == category:
match = re.compile(r'<p> <strong>(.*?)</strong> <span>(.*?)<br/>(.*?)</span> </p>',re.DOTALL).findall(replay)
if match:
for t,st,e in match:
title=t + '-' + st + '-' + e.replace(' ',' ')
img = re.findall('src="(.*?)"',replay) [0]
url= re.findall('href="(.*?)"',replay) [0]
iStart=url.find('VOD')
vodId= url[iStart:]
infoLabels={ "Title": title}
videos.append( [channel, vodId.encode("utf-8") , title.encode("utf-8") , img,infoLabels,'play'] )
return videos
示例12: list_shows
def list_shows(channel, folder):
shows = []
d = dict()
filePath = utils.downloadCatalog(url_xml, "ARTE.XML", False, {})
if folder == "none":
xml = open(filePath).read()
url = common.parseDOM(xml, "url")
for i in range(0, len(url)):
categoryTab = common.parseDOM(url[i], "video:category")
if len(categoryTab) > 0:
category = typo_correction(fix_text(categoryTab[0]))
if category not in d:
shows.append([channel, category, category, "", "folder"])
d[category] = category
else:
xml = open(filePath).read()
url = common.parseDOM(xml, "url")
for i in range(0, len(url)):
show_titleTab = common.parseDOM(url[i], "video:show_title")
if len(show_titleTab) > 0:
title = fix_text(show_titleTab[0])
categoryTab = common.parseDOM(url[i], "video:category")
if globalvar.ADDON.getSetting("arteFull") == "true":
videoTag = common.parseDOM(url[i], "video:tag")[0]
else:
videoTag = "ARTE+7"
if len(categoryTab) > 0:
if typo_correction(fix_text(categoryTab[0])) == folder and title not in d and videoTag == "ARTE+7":
shows.append([channel, title, title, "", "shows"])
d[title] = title
return shows
示例13: list_videos
def list_videos(channel,link):
videos=[]
filePath=utils.downloadCatalog('http://www.nrj-play.fr' + link,channel + link.replace('/','') +'.html',False,{})
html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace("\n", "")
html=' '.join(html.split())
print html
match = re.compile(r'<img itemprop="thumbnailUrl" src="(.*?)" class="thumbnail-img embed-responsive-item"(.*?)<h3 class="thumbnail-title" itemprop="name"> <a href="(.*?)">(.*?)</a> </h3>',re.DOTALL).findall(html)
if match:
for img,empty,link,title in match:
title = common.replaceHTMLCodes(title)
title = title.title()
infoLabels={ "Title": title}
videos.append( [channel, link , title , img,infoLabels,'play'] )
else:
match = re.compile(r'<meta itemprop="name" content="(.*?)" />',re.DOTALL).findall(html)
if match:
for title in match:
title = common.replaceHTMLCodes(title)
title = title.title()
infoLabels={ "Title": title}
videos.append( [channel, link , title , '',infoLabels,'play'] )
return videos
示例14: list_videos
def list_videos(channel,params):
videos = []
program_url = params.split('|')[0]
titre_program = params.split('|')[1]
filePath = utils.downloadCatalog(program_url,'telequebec_'+titre_program+'.html',False,{})
html = open(filePath).read().decode("utf-8")
# season_grid = common.parseDOM(html,"div",attrs={"class":"seasons-grid tab-season"})
# for season in season_grid:
# list_li = common.parseDOM(season,"li")
# for li in list_li:
# title_h5 = common.parseDOM(li,"h5")
# title = common.parseDOM(title_h5,"a")[0].encode('utf-8')
# #title = common.replaceHTMLCodes(title)
# url_show = common.parseDOM(title_h5,"a", ret="href")[0].encode('utf-8')
# url_show = url_root+url_show
# url_icon = common.parseDOM(li,"img", ret="src")[0].encode('utf-8')
# episode_number = common.parseDOM(li,"div", attrs={"class":"user-info"})
# episode_number = common.parseDOM(episode_number, "a")[0].encode('utf-8')
#videos.append([channel,program_url+'|'+'title','title','url_icon',{'Title':'title'+" - "+'episode_number'},'play'])
return videos
示例15: list_videos
def list_videos(channel,folder):
videos = []
uniqueItem = dict()
filePath = utils.downloadCatalog(channelCatalog % (channel),'%s.json' % (channel),False)
filPrgm = open(filePath).read()
jsonParser = json.loads(filPrgm)
emissions = jsonParser['reponse']['emissions']
for emission in emissions :
titre = emission['titre_programme'].encode('utf-8')
if titre==folder:
id_diffusion=emission['id_diffusion']
filPrgm = urllib2.urlopen(showInfo % (emission['id_diffusion'])).read()
jsonParserShow = json.loads(filPrgm)
plot = jsonParserShow['synopsis'].encode('utf-8')
date = jsonParserShow['diffusion']['date_debut']
if jsonParserShow['real_duration']!=None :
duration = jsonParserShow['real_duration']/60
titre = jsonParserShow['titre'].encode('utf-8')
if jsonParserShow['sous_titre']!='':
titre+=' - ' + jsonParserShow['sous_titre'].encode('utf-8')
image = imgURL % (jsonParserShow['image'])
infoLabels = { "Title": titre,"Plot":plot,"Aired":date,"Duration": duration, "Year":date[6:10]}
if jsonParserShow['genre']!='':
infoLabels['Genre']=jsonParserShow['genre'].encode('utf-8')
videos.append( [channel, id_diffusion, titre, image,infoLabels,'play'] )
return videos