Skip to content

Commit

Permalink
changed the way youtube-dl works. Xbmc doesnt handle the common way
Browse files Browse the repository at this point in the history
  • Loading branch information
sarak_000 authored and sarak_000 committed May 12, 2014
1 parent 7c6566b commit 99c8528
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
7 changes: 6 additions & 1 deletion default.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def onInit(self):
pass

def selectchoice():
success = False

Choice = ['1 - Proposition de films','2 - Voir mes bandes-annonces', '3 - Suggestions','4 - Rechercher un film','5 - Gestion des bandes-annonces','6 - Consulter sa wanted list','7 - Quitter']
selectedchoice = xbmcgui.Dialog().select(u"Que voulez vous faire ?", Choice)
if not selectedchoice == -1:
Expand Down Expand Up @@ -3126,9 +3126,12 @@ def getlibrary():
path=path.replace('\\','\\\\')
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %d , "trailer":"%s"}}' % (onlinetrailer[selectChoice]['movieid'],path.encode('utf-8')) )
xbmc.Player().play(path)
dp.close()
dp.create(u'Lecture de la bande annonce','','',u'Bande annonce récupérée')
sortiecinqun=True
while xbmc.Player().isPlaying():
xbmc.sleep(250)
dp.close()
else:
sortiecinqun=True
elif selectChoice==2:
Expand All @@ -3155,9 +3158,11 @@ def getlibrary():
path=path.replace('\\','\\\\')
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %d , "trailer":"%s"}}' % (notrailer[selectChoice]['movieid'],path.encode('utf-8')) )
xbmc.Player().play(path)
dp.create(u'Lecture de la bande annonce','','',u'Bande annonce récupérée')
sortiecinqdeux=True
while xbmc.Player().isPlaying():
xbmc.sleep(250)
dp.close()
else:
sortiecinqdeux=True
elif selectChoice==3:
Expand Down
46 changes: 36 additions & 10 deletions trailercatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def allocinesearch(self,moviename):

def quacontrol(self,url):
quallist=[]
p=subprocess.Popen([sys.executable, 'youtube_dl/__main__.py', '-F',url],cwd=rootDir, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p=subprocess.Popen([os.path.join(rootDir,'youtube-dl.exe'), '-F',url], shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
while p.poll() is None:
l = p.stdout.readline()
quallist.append(l)
Expand Down Expand Up @@ -342,6 +342,7 @@ def videodl(self,cleanlist,trailername,moviename,trailerpath,allo=False,maxheigh
try:
urllib.urlretrieve(linkallo, os.path.join(trailerpath,trailername)+'.'+extallo)
self.logg('Une bande annonce telechargee pour ' + moviename +' sur Allocine')

return trailerpath+'/'+trailername+'.'+extallo
break
except:
Expand All @@ -355,7 +356,7 @@ def videodl(self,cleanlist,trailername,moviename,trailerpath,allo=False,maxheigh
self.logg('En train de telecharger : ' + bo + ' pour ' +moviename)
tempdest=unicodedata.normalize('NFKD', os.path.join(rootDir,trailername.replace("'",''))).encode('ascii','ignore')+u'.%(ext)s'
dest=os.path.join(trailerpath,trailername)
p=subprocess.Popen([sys.executable, 'youtube_dl/__main__.py', '-o',tempdest,'--newline', '--max-filesize', '105m', '--format','best',bo],cwd=rootDir, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p=subprocess.Popen([os.path.join(rootDir,'youtube-dl.exe'), '-o',tempdest,'--newline', '--max-filesize', '105m', '--format','best',bo],shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
while p.poll() is None:
l = p.stdout.readline()
if 'download' in l:
Expand All @@ -374,13 +375,11 @@ def videodl(self,cleanlist,trailername,moviename,trailerpath,allo=False,maxheigh
shutil.move(listfile, destination)
bocount=1
self.logg('Une bande annonce telechargee pour ' + moviename)
if 'youtube' in bo:
countyoutube+=1
else:
countdaily+=1
return trailerpath+'/'+trailername+'.'+ext

return trailerpath+'/'+trailername+ext

except:
except Exception,e:
print str(e)
continue
else:
continue
Expand Down Expand Up @@ -431,10 +430,35 @@ def trailersearch(self,moviefolder):
trailername=movie[2]+'-trailer'
searchstring=moviename
listvfallo,listvostfrallo,listvoallo=self.allocinesearch(moviename)

if listvfallo:
maxqual=self.quacontrolallo(listvfallo,'vf')

for url in listvfallo:
if maxqual==url['height']:
xbmc.Player().play(url['link'])
dp.close()
xbmc.sleep(500)
dp.create(u'Lecture dune bande annonce provisoire','','',u'en attendant la recherche et le téléchargement')

elif listvostfrallo:
maxqual=self.quacontrolallo(listvostfrallo,'vostfr')
for url in listvostfrallo:
if maxqual==url['height']:
xbmc.Player().play(url['link'])
dp.close()
xbmc.sleep(500)
dp.create(u'Lecture dune bande annonce provisoire','','',u'en attendant la recherche et le téléchargement')

elif listvoallo:
maxqual=self.quacontrolallo(listvoallo,'vo')
for url in listvoallo:
if maxqual==url['height']:
xbmc.Player().play(url['link'])
xbmc.sleep(1000)
dp.close()
dp.create(u'Lecture dune bande annonce provisoire','','',u'en attendant la recherche et le téléchargement')
if listvfallo:
maxqual=self.quacontrolallo(listvfallo,'vf')

if maxqual>=481:
dp.close()
dp.create(u'Téléchargement','','','Bande annonce en VF en cours')
Expand Down Expand Up @@ -500,6 +524,7 @@ def trailersearch(self,moviefolder):
return path
elif listvostfrallo:
maxqual=self.quacontrolallo(listvostfrallo,'vostfr')

if maxqual>=481:
dp.close()
dp.create(u'Téléchargement','','','Bande annonce en VOST en cours')
Expand Down Expand Up @@ -555,6 +580,7 @@ def trailersearch(self,moviefolder):
return path
elif listvoallo:
maxqual=self.quacontrolallo(listvoallo,'vo')

if maxqual>=481:
dp.close()
dp.create(u'Téléchargement','','','Bande annonce en VO en cours')
Expand Down
Binary file added youtube-dl.exe
Binary file not shown.

0 comments on commit 99c8528

Please sign in to comment.