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
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
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
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
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
def list_shows(channel,folder): shows = [] uniqueItem = dict() filePath = utils.downloadCatalog(channelCatalog % (channel),'%s.json' % (channel),False) filPrgm = open(filePath).read() jsonParser = json.loads(filPrgm) emissions = jsonParser['reponse']['emissions'] if folder=='none': for emission in emissions : rubrique = emission['rubrique'].title().encode('utf-8') if rubrique not in uniqueItem: uniqueItem[rubrique] = rubrique shows.append( [channel,rubrique, rubrique,'','folder'] ) else: for emission in emissions : rubrique = emission['rubrique'].title().encode('utf-8') if rubrique==folder: titre = emission['titre_programme'].encode('utf-8') if titre!='': id = emission['id_programme'].encode('utf-8') if id=='': id = emission['id_emission'].encode('utf-8') if id not in uniqueItem: uniqueItem[id]=id shows.append( [channel,id,titre,imgURL % (emission['image_large']),'shows'] ) return shows
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'<h3 class="thumbnailReplay-title" itemprop="name"> <a href="(.*?)">(.*?)</a> </h3>',re.DOTALL).findall(html) if match: for link,title in match: title = common.replaceHTMLCodes(title) title = title.title() infoLabels={ "Title": title} videos.append( [channel, link , title , '',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
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
def list_shows(channel, param): shows = [] filePath = utils.downloadCatalog( 'http://www.tou.tv/presentation/section/a-z?AkamaiDevice=phone&smallWidth=320&mediumWidth=640&largeWidth=640&isPhone=True', 'TouTV.json', False, {}) filPrgm = open(filePath).read() jsonParser = json.loads(filPrgm) if param == 'none': for menu in jsonParser['Lineups']: shows.append([ channel, menu['Name'], menu['Title'].encode('utf-8'), '', 'folder' ]) else: for menu in jsonParser['Lineups']: if param == menu['Name']: for item in menu['LineupItems']: if item['BookmarkKey']: shows.append([ channel, item['Url'], item['Title'].encode('utf-8'), item['ImageUrl'], 'shows' ]) return shows
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
def list_shows(channel,folder): shows=[] filePath=utils.downloadCatalog('http://www.nrj12.fr/replay-4203/collectionvideo/','NRJ12.html',False,{}) html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a') if folder=='none': match = re.compile(r'<a href="#" rel="nofollow" class="nocursor">(.*?)</a>',re.DOTALL).findall(html) if match: for title in match: shows.append( [channel,title, title , '','folder'] ) else: line_replay_s = common.parseDOM(html,"div",attrs={"class":"line replay"}) for line_replay in line_replay_s : Categorie = common.parseDOM(line_replay,"a",attrs={"class":"nocursor"}) [0] if Categorie.encode("utf-8") == folder: li_s = common.parseDOM(line_replay,"li",attrs={"id":u"*"}) for li in li_s : replay_hover_s = common.parseDOM(li,"div",attrs={"class":u"replay_hover"}) if replay_hover_s : image_div = common.parseDOM(li,"div",attrs={"class":"image"}) [0] image_a_u = common.parseDOM(image_div,"a") [0] image_url = re.findall(""".*src="(.*)">""",image_a_u) [0] titre_p = common.parseDOM(li,"p",attrs={"class":"titre"}) [0] titre_u = common.parseDOM(titre_p,"a") [0] titre = titre_u.encode("utf-8") shows.append( [channel,titre, titre , image_url, 'shows'] ) return shows
def list_videos(channel, show): videos = [] link = show.split('|')[0] title = show.split('|')[1] filePath = utils.downloadCatalog(link, channel + '_' + title + '.html', False, {}) html = open(filePath).read() match = re.compile( r'<li data-icon="false">(.*?)<a href="(.*?)">(.*?)<img src="(.*?)"/>(.*?)<p class="ui-li-aside">(.*?)</p>(.*?)<h3>(.*?)</h3>(.*?)<p>(.*?)</p>(.*?)</li>', re.DOTALL).findall(html) if match: for empty1, link, empty2, img, empty3, date, empty4, title, empty5, desc, empy6 in match: link = url_root + link desc = " ".join(desc.split()) date = date.split() day = date[0] mounth = get_mounth_number(date[1]) year = date[2] date2 = day + "/" + mounth + "/" + year infoLabels = { "Title": title, "Plot": desc, "Aired": date2, "Year": year } videos.append([channel, link, title, img, infoLabels, 'play']) return videos
def getVideoURL(channel, idVideo): filePath = utils.downloadCatalog(url_base + idVideo, 'futuravideo.html', True, {}) html = open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '') url = da = re.findall('src="http://www.dailymotion.com(.*?)"', html)[0] return utils.getDMURL('http://www.dailymotion.com' + url)
def list_shows(channel, folder): shows = [] d = dict() filePath = utils.downloadCatalog( 'http://www.arte.tv/papi/tvguide-flow/sitemap/feeds/videos/F.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 = 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)): titleTab = common.parseDOM(url[i], "video:title") if len(titleTab) > 0: title = fix_text(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 (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
def list_videos(channel,show_title): videos=[] filePath=utils.downloadCatalog('http://www.tv5mondeplusafrique.com/dotscreen/exportAfrique.xml','TV5AF.XML',False,{}) xml = open(filePath).read() item=common.parseDOM(xml, "item") lids = common.parseDOM(xml, "item", ret = "lid") for i in range(0, len(item)): titres=common.parseDOM(item[i], "titre") if len(titres)>0: titre=titres[0] titre=titre[9:-3] if '-EP' in titre: titreFilter=titre[:titre.find('-EP')] titre=titre[titre.find('-EP')+1:] if titreFilter==show_title: plots=common.parseDOM(item[i], "descriptif") if len(plots)>0: plot=plots[0] plot=plot[9:-3] durees=common.parseDOM(item[i], "duree") if len(durees)>0: sDuree=durees[0] duree=int(sDuree[0:2])*60+int(sDuree[3:5]) dates=common.parseDOM(item[i], "dateCreation") if len(dates)>0: date=dates[0] infoLabels={ "Title": titre,"Plot":plot,"Aired":date,"Duration": duree} videos.append( [channel, lids[i], titre.encode('utf-8'), urlIMG % (lids[i]),infoLabels,'play'] ) return videos
def list_videos(channel, param): videos = [] filePath = utils.downloadCatalog(urlCatalog, 'TouTV.json', False, {}) filPrgm = open(filePath).read() jsonParser = json.loads(filPrgm) for lineup in jsonParser['Lineups']: for lineupitem in lineup['LineupItems']: if canPlay(lineupitem): if lineupitem['Title'] is not None: if lineupitem['Title'].encode('utf-8') == param: details = lineupitem['Details'] plot = details['Description'].encode('utf-8') duration = details['Length'] / 60 titre = param if lineupitem['PromoDescription'] is not None: titre += '-' + lineupitem[ 'PromoDescription'].encode('utf-8') image = details['ImageUrl'].encode('utf-8') url = lineupitem['Url'].encode('utf-8') infoLabels = { "Title": titre, "Plot": plot, "Duration": duration } videos.append( [channel, url, titre, image, infoLabels, 'play']) return 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
def list_videos(channel,param): folder=param.split('$$')[0] category=param.split('$$')[1] videos=[] cpt=0 cptStr='' while cpt != -1: filePath=utils.downloadCatalog(urlBase + folder + cptStr,'gulli' + folder + str(cpt) +'.html',False,{}) html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace("\n", " ") uls = common.parseDOM(html,"ul",attrs={"class":"block_content clearfix"}) for ul in uls: replays = common.parseDOM(ul,"li") for replay in replays : title = (common.parseDOM(replay,"span",attrs={"class":"title"}) [0]).encode("utf-8") if title == category: cpt=-1 title=(htmlParser.unescape(common.parseDOM(replay,"span",attrs={"class":"episode_title"}) [0])).encode("utf-8") img = 'http://' + 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 , img,infoLabels,'play'] ) if len(uls) != 0 and cpt != -1: cpt=cpt+1 cptStr='/'+str(cpt) else: cpt=-1 return videos
def list_shows(channel,folder): shows=[] d=dict() filePath=utils.downloadCatalog('http://www.arte.tv/papi/tvguide-flow/sitemap/feeds/videos/F.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=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)): titleTab=common.parseDOM(url[i], "video:title") if len(titleTab)>0: title=fix_text(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(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
def list_shows(channel,folder): shows=[] if folder=='none': shows.append( [channel,'dessins-animes','Dessins Animes','','folder'] ) shows.append( [channel,'emissions','Emissions','','folder'] ) shows.append( [channel,'series','Series et films','','folder'] ) else: d=dict() cpt=0 cptStr='/' while cpt != -1: filePath=utils.downloadCatalog(urlBase + folder + cptStr,'gulli' + folder + str(cpt) +'.html',False,{}) html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a') replays = common.parseDOM(html,"div",attrs={"class":"block_category clearfix"}) for replay in replays : title = (htmlParser.unescape(common.parseDOM(replay,"span",attrs={"class":"title"}) [0])).encode("utf-8") if title not in d: img = 'http://' + re.findall('src="//(.*?)"',replay) [0] shows.append( [channel,folder + '$$' + title,title,img.encode("utf-8"),'shows'] ) d[title]=title if len(replays) != 0: cpt=cpt+1 cptStr='/'+str(cpt) else: cpt=-1 return shows
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
def getVideoURL(channel,slug): filePath = utils.downloadCatalog(url_video % slug, 'vtelevideo.html', True, {}) html = open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace("\n", "") da=re.findall('data-account="(.*?)"', html)[0] vid=re.findall('data-video-id="(.*?)"', html)[0] filePath = utils.downloadCatalog(url_video_json % (da,vid), 'VTELE%s.json' % vid, True, {}, {'Accept':'application/json;pk=BCpkADawqM145C2ijKGLTnwjc7d61ZlONDwMyE_8xJ-8UVM6hjWtMzw5gMSTc3xniaSHQAJ7Mj23t6tajoj7IQdwFuqpwLac1Gm0L6F11zSTeSWfsOW2KF83_vo'}) filPrgm = open(filePath).read() print filPrgm jsonParser = json.loads(filPrgm) print len(jsonParser['sources']) for i in range(len(jsonParser['sources'])) : src=jsonParser['sources'][i] if ('type') in src: if(src['type']=='application/x-mpegURL'): return src['src']
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
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;
def list_videos(channel,show): videos=[] filePath=utils.downloadCatalog('http://www.nrj12.fr/replay-4203/collectionvideo/','NRJ12.html',False,{}) html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a') line_replay_s = common.parseDOM(html,"div",attrs={"class":"line replay"}) for line_replay in line_replay_s : li_s = common.parseDOM(line_replay,"li",attrs={"id":u"*"}) for li in li_s : replay_hover_s = common.parseDOM(li,"div",attrs={"class":u"replay_hover"}) if replay_hover_s : titre_p = common.parseDOM(li,"p",attrs={"class":"titre"}) [0] titre_u = common.parseDOM(titre_p,"a") [0] titre = titre_u.encode("utf-8") if titre==show: replay_hover = replay_hover_s[0] content_ul = common.parseDOM(replay_hover,"ul",attrs={"class":"content"}) [0] li_s = common.parseDOM(content_ul,"li") for li in li_s : image_div = common.parseDOM(li,"div",attrs={"class":"image"}) [0] url= re.findall(""".*href="(.*)" title.*>""",image_div) [0] image_a_u = common.parseDOM(image_div,"a") [0] image_url = re.findall(""".*src="(.*)".*>""",image_a_u) [0] titre_p = common.parseDOM(li,"p",attrs={"class":"titre"}) [0] titre_u = common.parseDOM(titre_p,"a") [0] titre = show+" : "+titre_u.encode("utf-8") date=common.parseDOM(li,"p",attrs={"class":"date"}) [0] infoLabels={ "Title": titre,"Aired":date, "Year":date[:4]} videos.append( [channel, url, titre, image_url,infoLabels,'play'] ) return videos
def get_search_url_for_emission(channel, emission_page): emission_page = root_url + emission_page tempfile = "%s_details_%s.html "%(channel, emission_page) file_path = utils.downloadCatalog(emission_page, tempfile, bypass_cache,{}) raw = open(file_path).read() result = detail_re.search(raw) return root_url + result.group(1) + '?' + result.group(2)
def list_videos(channel, url): videos = [] cat, sub, id = url.split('|') url = 'https://www.ina.fr/layout/set/ajax/recherche/result?q=tree%3A%28Top%2Fina%2Fogpv3%2Frubrique%2Faudiovideo%2F' + cat + '%2F' + sub + '%29&autopromote=0&c=ina_rubrique&b=' + id + '&type=Video&typeBlock=ina_resultat_exalead&r=Top%2Fina%2Fpremium%2Fnon' filePath = utils.downloadCatalog(url, sub + '.html', False, {}) html = open(filePath).read().replace('\xe9', 'e').replace( '\xe0', 'a').replace('\\n', ' ').replace('\r', '').replace('\\t', '').replace("\\", "") if id != '0': videos.append([ channel, cat + '|' + sub + '|' + str(int(id) - 24), '<<Page Precedente', '', {}, 'shows' ]) match = re.compile(r'href="(.*?)"> <img src="(.*?)" alt="(.*?)">', re.DOTALL).findall(html) for url, img, title in match: title = title.encode('utf-8') infoLabels = {"Title": title} idVideo = url[7:url.find('/', 7)] videos.append([ channel, idVideo, title.encode('utf-8'), img.encode('utf-8'), infoLabels, 'play' ]) videos.append([ channel, cat + '|' + sub + '|' + str(int(id) + 24), 'Page Suivante>>', '', {}, 'shows' ]) return videos
def list_shows(channel,folder): shows = [] filePath = utils.downloadCatalog(url_catalog,'cherie25.html',False) html = open(filePath).read().decode("utf-8") line_s = common.parseDOM(html,"div",attrs={"class":u"line replay magazines"}) for line in line_s : title = common.parseDOM(line,"div",attrs={"class":"title"})[0] categorie_name = common.parseDOM(title,"span")[0].encode("utf-8") if folder=='none' : shows.append([channel,categorie_name,categorie_name,'','folder']) elif folder==categorie_name : li_s = common.parseDOM(line,"li",attrs={"id":"liste_[0-9]"}) for li in li_s : replay_hover_s = common.parseDOM(li,"div",attrs={"class":u"replay_hover"}) if replay_hover_s : image_div = common.parseDOM(li,"div",attrs={"class":"image"})[0] image_a_u = common.parseDOM(image_div,"a")[0] image_url = common.parseDOM(image_a_u,"img",ret="src")[0] titre_p = common.parseDOM(li,"p",attrs={"class":"titre"})[0] titre_u = common.parseDOM(titre_p,"a")[0] titre = titre_u.encode("utf-8") shows.append([channel,titre+'|'+image_url,titre,image_url,'shows']) else : image_div = common.parseDOM(li,"div",attrs={"class":"image"})[0] image_a_u = common.parseDOM(image_div,"a")[0] image_url = common.parseDOM(image_a_u,"img",ret="src")[0] titre_p = common.parseDOM(li,"p",attrs={"class":"titre"})[0] titre_u = common.parseDOM(titre_p,"a")[0] titre = titre_u.encode("utf-8") video_url_u = url_root+common.parseDOM(titre_p,"a",ret="href")[0] video_url = video_url_u.encode("utf-8") shows.append([channel,video_url+'|'+titre,titre,image_url,'shows']) return shows
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
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
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
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
def list_videos(channel,show_title): videos=[] filePath=utils.downloadCatalog('http://www.arte.tv/papi/tvguide-flow/sitemap/feeds/videos/F.xml','ARTE.XML',False,{}) xml = open(filePath).read() url=common.parseDOM(xml, "url") for i in range(0, len(url)): titleTab=common.parseDOM(url[i], "video:title") if len(titleTab)>0: title=fix_text(titleTab[0]) if(title==show_title): name='' image_url='' date='' duration='' views='' desc='' rating='' tmpTab=common.parseDOM(url[i], "video:publication_date") if len(tmpTab)>0: date=tmpTab[0][:10] tmpTab=common.parseDOM(url[i], "video:duration") if len(tmpTab)>0: duration=float(tmpTab[0])/60 tmpTab=common.parseDOM(url[i], "video:view_count") if len(tmpTab)>0: views=tmpTab[0] tmpTab=common.parseDOM(url[i], "video:rating") if len(tmpTab)>0: rating=tmpTab[0] descriptionTab=common.parseDOM(url[i], "video:description") if len(descriptionTab)>0: name=fix_text(descriptionTab[0]) desc=fix_text(descriptionTab[0]) tmpTab=common.parseDOM(url[i],"video:player_loc") if len(tmpTab)>0: if tmpTab[0]=="1": tmpTab=common.parseDOM(url[i], "video:id") if len(tmpTab)>0: video_id=tmpTab[0][28:28+10] + "_PLUS7-F" else: start=tmpTab[0].find("%2Fplayer%2FF%2F") end=tmpTab[0].find("%2F", start+16) video_id=tmpTab[0][start+16:end] if video_id.find("EXTRAIT")>0 : name="Extrait-" + name videoTag=common.parseDOM(url[i], "video:tag")[0] picTab=common.parseDOM(url[i], "video:thumbnail_loc") if len(picTab)>0: image_url=picTab[0] infoLabels={ "Title": name,"Plot":desc,"Aired":date,"Duration": duration, "Year":date[:4]} if not(globalvar.ADDON.getSetting('arteFull')=='true' and videoTag!='ARTE+7'): videos.append( [channel, video_id, name, image_url,infoLabels,'play'] ) return videos
def get_search_url_for_emission(channel, emission_page): emission_page = root_url + emission_page tempfile = "%s_details_%s.html " % (channel, emission_page) file_path = utils.downloadCatalog(emission_page, tempfile, bypass_cache, {}) raw = open(file_path).read() result = detail_re.search(raw) return root_url + result.group(1) + '?' + result.group(2)
def getVideoURL(channel,idVideo): filePath=utils.downloadCatalog('https://player.ina.fr/notices/%s.mrss' % (idVideo),'ina%s.xml' % (idVideo),False,{}) xml=open(filePath).read() url=re.findall('<media:content url="(.*?)"', xml)[0] return url
def getVideoURL(channel,vidId): encoded = base64.b64encode(json_video % vidId) encoded=encoded.replace('=','%3D') filePath=utils.downloadCatalog(url_video % (encoded),'natgeo%s.json' % (vidId),False,{}) txt=open(filePath).read() url=re.findall('releaseUrl =(.*?);', txt)[0] url='http:' + url.replace('\u0022','').replace('\u0026','&').replace('\/','/').replace(' ','').encode('utf-8') filePath=utils.downloadCatalog(url,'natgeo%s.txt' % (vidId),False,{}) txt=open(filePath).read() url=re.findall('<video src="(.*?)"', txt)[0] return url
def getVideoURL(channel, idVideo): filePath = utils.downloadCatalog( 'https://player.ina.fr/notices/%s.mrss' % (idVideo), 'ina%s.xml' % (idVideo), False, {}) xml = open(filePath).read() url = re.findall('<media:content url="(.*?)"', xml)[0] return url
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"> <a href="(.*?)">(.*?)</a> </h2>', re.DOTALL).findall(html) print 'rr' if match: for link, title in match: print 'ff' title = common.replaceHTMLCodes(title) title = title.title() shows.append( [channel, link, title.encode("utf-8"), '', 'shows']) return shows
def list_shows(channel,folder): shows = [] filePath=utils.downloadCatalog('http://becurioustv.com/' ,'becurioustv.html',False,{}) html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '') match = re.compile(r'<h2><a class="category-link" href="(.*?)"><img class="category-logo" src="(.*?)"> <span>(.*?)</span></a></h2>',re.DOTALL).findall(html) for url,img,title in match: shows.append( [channel,url, title.encode('utf-8') ,img ,'shows'] ) return shows
def getVideoURL(channel,idVideo): filePath=utils.downloadCatalog('http://www.allocine.fr/ws/AcVisiondataV4.ashx?media=%s' % (idVideo),'allocine%s.xml' % (idVideo),False,{}) xml=open(filePath).read() ld=re.findall('ld_path="(.*?)"', xml)[0] md=re.findall('md_path="(.*?)"', xml)[0] hd=re.findall('hd_path="(.*?)"', xml)[0] return hd
def getVideoURL(channel,asset_id): print("INA get video URL: " + asset_id) url = root_url + asset_id tempfile = "%s_videourl_%s.html"%(channel, asset_id) file_path = utils.downloadCatalog(url, tempfile, False,{}) raw = open(file_path).read() videolink = emission_url_re.search(raw).group(1) print("%s: Video link for asset %s : %s"%(channel, asset_id, videolink)) return videolink
def getVideoURL(channel, asset_id): print("INA get video URL: " + asset_id) url = root_url + asset_id tempfile = "%s_videourl_%s.html" % (channel, asset_id) file_path = utils.downloadCatalog(url, tempfile, False, {}) raw = open(file_path).read() videolink = emission_url_re.search(raw).group(1) print("%s: Video link for asset %s : %s" % (channel, asset_id, videolink)) return videolink
def list_videos(channel, folder): videos = [] 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: id = emission['id_programme'].encode('utf-8') if id == '': id = emission['id_emission'].encode('utf-8') if id == folder: titre = '' plot = '' duration = 0 date = '' id_diffusion = emission['id_diffusion'] print 'URL :' + showInfo % (emission['id_diffusion']) filPrgm = utils.get_webcontent( showInfo % (emission['id_diffusion'])) if(filPrgm != ''): jsonParserShow = json.loads(filPrgm) if jsonParserShow['synopsis']: plot = jsonParserShow['synopsis'].encode('utf-8') if jsonParserShow['diffusion']['date_debut']: date = jsonParserShow['diffusion']['date_debut'] date = date.encode('utf-8') if jsonParserShow['real_duration']: duration = int(jsonParserShow['real_duration']) if jsonParserShow['titre']: 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.split(' ')[0], "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
def getVideoURL(channel, vidId): encoded = base64.b64encode(json_video % vidId) encoded = encoded.replace('=', '%3D') filePath = utils.downloadCatalog(url_video % (encoded), 'natgeo%s.json' % (vidId), False, {}) txt = open(filePath).read() url = re.findall('releaseUrl =(.*?);', txt)[0] url = 'http:' + url.replace('\u0022', '').replace('\u0026', '&').replace( '\/', '/').replace(' ', '').encode('utf-8') filePath = utils.downloadCatalog(url, 'natgeo%s.txt' % (vidId), False, {}) txt = open(filePath).read() url = re.findall('<video src="(.*?)"', txt)[0] return url
def list_shows(channel,folder): shows = [] if folder == 'none': filePath = utils.downloadCatalog(url_themes, 'VTELE.JSON', False, {}) filPrgm = open(filePath).read() jsonParser = json.loads(filPrgm) for em in jsonParser['data']['results']: shows.append( [channel,em['slug'], em['title'].encode('utf-8'),em['header']['url-list'],'folder'] ) else: filePath = utils.downloadCatalog(url_themes, 'VTELE.JSON', False, {}) filPrgm = open(filePath).read() jsonParser = json.loads(filPrgm) for em in jsonParser['data']['results']: if em['slug']==folder: for sub in em['subthemes']: shows.append( [channel,sub['id'], sub['title'].encode('utf-8'),'','shows'] ) return shows
def list_shows(channel, folder): shows = [] uniqueItem = dict() realChannel = channel if channel == 'la_1ere': realChannel = 'la_1ere_reunion%2C' \ 'la_1ere_guyane%2C' \ 'la_1ere_polynesie%2C' \ 'la_1ere_martinique%2C' \ 'la_1ere_mayotte%2C' \ 'la_1ere_nouvellecaledonie%2C' \ 'la_1ere_guadeloupe%2C' \ 'la_1ere_wallisetfutuna%2C' \ 'la_1ere_saintpierreetmiquelon' url_json = channelCatalog % (realChannel) filePath = utils.downloadCatalog(url_json, '%s.json' % (channel), False, {}) filPrgm = open(filePath).read() jsonParser = json.loads(filPrgm) emissions = jsonParser['reponse']['emissions'] if folder == 'none': for emission in emissions: rubrique = emission['rubrique'].encode('utf-8') if rubrique not in uniqueItem: uniqueItem[rubrique] = rubrique shows.append([ channel, rubrique, change_to_nicer_name(rubrique), '', 'folder']) else: for emission in emissions: rubrique = emission['rubrique'].encode('utf-8') if rubrique == folder: titre = emission['titre_programme'].encode('utf-8') if titre != '': id = emission['id_programme'].encode('utf-8') if id == '': id = emission['id_emission'].encode('utf-8') if id not in uniqueItem: uniqueItem[id] = id shows.append([ channel, id, titre, imgURL % (emission['image_large']), 'shows']) return shows
def list_videos(channel, show): videos = [] filePath = utils.downloadCatalog( 'http://www.nrj12.fr/replay-4203/collectionvideo/', 'NRJ12.html', False, {}) html = open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a') line_replay_s = common.parseDOM(html, "div", attrs={"class": "line replay"}) for line_replay in line_replay_s: li_s = common.parseDOM(line_replay, "li", attrs={"id": u"*"}) for li in li_s: replay_hover_s = common.parseDOM(li, "div", attrs={"class": u"replay_hover"}) if replay_hover_s: titre_p = common.parseDOM(li, "p", attrs={"class": "titre"})[0] titre_u = common.parseDOM(titre_p, "a")[0] titre = titre_u.encode("utf-8") if titre == show: replay_hover = replay_hover_s[0] content_ul = common.parseDOM(replay_hover, "ul", attrs={"class": "content"})[0] li_s = common.parseDOM(content_ul, "li") for li in li_s: image_div = common.parseDOM(li, "div", attrs={"class": "image"})[0] url = re.findall(""".*href="(.*)" title.*>""", image_div)[0] image_a_u = common.parseDOM(image_div, "a")[0] image_url = re.findall(""".*src="(.*)".*>""", image_a_u)[0] titre_p = common.parseDOM(li, "p", attrs={"class": "titre"})[0] titre_u = common.parseDOM(titre_p, "a")[0] titre = show + " : " + titre_u.encode("utf-8") date = common.parseDOM(li, "p", attrs={"class": "date"})[0] infoLabels = { "Title": titre, "Aired": date, "Year": date[:4] } videos.append([ channel, url, titre, image_url, infoLabels, 'play' ]) return videos
def getToken(): login = globalvar.ADDON.getSetting('watLogin') pwd = globalvar.ADDON.getSetting('watPwd') filePath = utils.downloadCatalog( 'https://www.wat.tv/v4/appmobile/user/authentication', 'WatAuth.html', False, { 'username': login, 'password': pwd }) jsonFile = open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a') print jsonFile
def list_shows(channel,param): shows=[] filePath=utils.downloadCatalog('http://api.france24.com/fr/services/json-rpc/emission_list?databases=f24fr&key=XXX&start=0&limit=30&edition_limit=8','France24.json',False,{}) filPrgm=open(filePath).read() jsonParser = json.loads(filPrgm) for item in jsonParser['result']['f24fr']['list'] : shows.append( [channel,item['nid'], item['title'].encode('utf-8'),item['image'][0]['original'].encode('utf-8'),'shows']) return shows
def list_shows(channel,folder): shows=[] for i in range(0, int(globalvar.ADDON.getSetting('tf1ThemePages'))): filePath=utils.downloadCatalog('http://www.%s.fr/videos?page=%s' % (channel,i),'%s%s.html' % (channel,i),False,{}) html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a') items=re.findall(r'src="(.*?)"/> </a></div> <div class="views-field views-field-title"> <span class="field-content"><a href="(.*?)">(.*?)</a></span>', html.replace('\n', ' ').replace('\r', '')) for item in items: shows.append( [channel,item[1], item[2] , 'http://www.%s.fr/%s' % (channel,item[0]),'shows'] ) return shows
def list_videos(channel, folder): cat, page = folder.split('|') videos = [] filePath = utils.downloadCatalog( 'http://www.allocine.fr/' + cat + '/?page=' + page, 'allocine' + cat + '-' + page + '.html', False, {}) html = open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace( '\n', ' ').replace('\r', '') print html 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'<div class="layer-link-holder"><a href="/video/player_gen_cmedia=(.*?)&cfilm=(.*?).html" class="layer-link">(.*?)</a></div>', re.DOTALL).findall(html) if match: for id, movie, title in match: title = title.replace('<strong>', '').replace('</strong>', '') infoLabels = {"Title": title} videos.append([channel, id, title, '', infoLabels, 'play']) match = re.compile( r'<h3 class="title "> <span > <a href="/video/video-(.*?)/" itemprop="url">(.*?)</a> </span> </h3>', re.DOTALL).findall(html) if match: for link, title in match: title = title.replace('<strong>', '').replace('</strong>', '') infoLabels = {"Title": title} videos.append([channel, idVideo, title, '', infoLabels, 'play']) if next: shows.append([ channel, cat + '-' + str(int(page) + 1), 'Page Suivante>>', '', {}, 'folder' ]) return videos
def getVideoURL(channel,link): 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'<meta itemprop="contentUrl" content="(.*?)" alt="',re.DOTALL).findall(html) url=match[0] return url
def getVideoURL(channel, url): filePath = utils.downloadCatalog(url, 'aufem' + url[-12:], False, {}) html = open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace( '\n', ' ').replace('\r', '') print html urls = re.compile(r'<source src="(.*?)"', re.DOTALL).findall(html) for url in urls: if 'HD.mp4' in url: url_video = url return url_video
def list_videos(channel,show_url): videos=[] filePath=utils.downloadCatalog('http://www.allocine.fr%s' % (show_url),'allocine%s.html' % (show_url.replace('/','')),False,{}) html=open(filePath).read().replace('\xe9', 'e').replace('\xe0', 'a').replace('\n', ' ').replace('\r', '') items=re.findall('<h3 class="title "> <span > <a href="/video/video-(.*?)/" itemprop="url">(.*?)</a>', html) for item in items: infoLabels={ "Title": formatTitle(item[1])} videos.append( [channel, item[0], formatTitle(item[1]), '',infoLabels,'play'] ) return videos
def list_shows(channel, folder): shows = [] filePath = utils.downloadCatalog(url_catalog, 'cherie25.html', False, {}) html = open(filePath).read().decode("utf-8") line_s = common.parseDOM(html, "div", attrs={"class": u"line replay magazines"}) for line in line_s: title = common.parseDOM(line, "div", attrs={"class": "title"})[0] categorie_name = common.parseDOM(title, "span")[0].encode("utf-8") if folder == 'none': shows.append( [channel, categorie_name, categorie_name, '', 'folder']) elif folder == categorie_name: li_s = common.parseDOM(line, "li", attrs={"id": "liste_[0-9]"}) for li in li_s: replay_hover_s = common.parseDOM( li, "div", attrs={"class": u"replay_hover"}) if replay_hover_s: image_div = common.parseDOM(li, "div", attrs={"class": "image"})[0] image_a_u = common.parseDOM(image_div, "a")[0] image_url = common.parseDOM(image_a_u, "img", ret="src")[0] titre_p = common.parseDOM(li, "p", attrs={"class": "titre"})[0] titre_u = common.parseDOM(titre_p, "a")[0] titre = titre_u.encode("utf-8") shows.append([ channel, titre + '|' + image_url, titre, image_url, 'shows' ]) else: image_div = common.parseDOM(li, "div", attrs={"class": "image"})[0] image_a_u = common.parseDOM(image_div, "a")[0] image_url = common.parseDOM(image_a_u, "img", ret="src")[0] titre_p = common.parseDOM(li, "p", attrs={"class": "titre"})[0] titre_u = common.parseDOM(titre_p, "a")[0] titre = titre_u.encode("utf-8") video_url_u = url_root + common.parseDOM( titre_p, "a", ret="href")[0] video_url = video_url_u.encode("utf-8") shows.append([ channel, video_url + '|' + titre, titre, image_url, 'shows' ]) return shows
def list_shows(channel, page): shows = [] filePath = utils.downloadCatalog(url_themes, 'bsport.JSON', False, {}) filPrgm = open(filePath).read() jsonParser = json.loads(filPrgm) for item in jsonParser['hydra:member'][0]['dropdownEntries']: id = item['taxonomy']['@id'] id = id.replace('/taxonomies/', '') title = item['taxonomy']['name'] shows.append([channel, id, title, '', 'shows']) return shows
def list_videos(channel, params): videos = [] if params == 'reportages': filePath = utils.downloadCatalog(url_catalog, '%s.xml' % (channel), False, {}) fileCat = open(filePath).read().replace('\n', '').decode('utf-8') cat = re.findall('<key>' + params + '</key> +<array> +(.+?) +</array>', fileCat)[0] else: cat = utils.get_webcontent(params).replace('\n', '').decode('utf-8') video_s = re.findall('<dict> +(.+?) +</dict>', cat) for video in video_s: video_title, video_thumb, video_infos, video_url = parse_dict(video) videos.append([channel, video_url, video_title, video_thumb, video_infos, 'play']) return videos
def list_videos(channel,page): videos=[] filePath=utils.downloadCatalog('http://rmcdecouverte.bfmtv.com/mediaplayer-replay/' ,'rmcd.html',False,{}) html=open(filePath).read().replace('\n', ' ').replace('\r', '') match = re.compile(r'<figure class="figure modulx1-5-inside-bloc">(.*?)<a href="(.*?)" title="(.*?)">(.*?)data-original="(.*?)" alt=',re.DOTALL).findall(html) for a,url,title,b,img in match: title=utils.formatName(title) infoLabels = {"Title": title.encode('utf-8')} videos.append( [channel, url.replace('\t','').encode('utf-8') , title.encode('utf-8') , img.encode('utf-8'),infoLabels,'play'] ) return videos