def download(self, item):
     downloads = self.settings['downloads']
     if '' == downloads:
         xbmcgui.Dialog().ok(self.provider.name, xbmcutil.__lang__(30009))
         return
     stream = self.resolve(item['url'])
     if stream:
         if not 'headers' in list(stream.keys()):
             stream['headers'] = {}
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/download')
         # clean up \ and /
         name = item['title'].replace('/', '_').replace('\\', '_')
         if not stream['subs'] == '':
             xbmcutil.save_to_file(stream['subs'],
                                   os.path.join(downloads, name + '.srt'),
                                   stream['headers'])
         dot = name.find('.')
         if dot <= 0:
             # name does not contain extension, append some
             name += '.mp4'
         xbmcutil.download(self.addon,
                           name,
                           self.provider._url(stream['url']),
                           os.path.join(downloads, name),
                           headers=stream['headers'])
Пример #2
0
 def play(self, item):
     stream = self.resolve(item['url'])
     print(type(stream))
     if type(stream) == type([]):
         # resolved to mutliple files, we'll feed playlist and play the first one
         playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
         playlist.clear()
         for video in stream:
             li = xbmcgui.ListItem(label=video['title'], path=video['url'])
             li.setArt({'icon': 'DefaultVideo.png'})
             playlist.add(video['url'], li)
         stream = stream[0]
     if stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/play')
         if 'headers' in stream.keys():
             for header in stream['headers']:
                 stream['url'] += '|%s=%s' % (header,
                                              stream['headers'][header])
         print('Sending %s to player' % stream['url'])
         li = xbmcgui.ListItem(path=stream['url'])
         li.setArt({'icon': 'DefaultVideo.png'})
         if stream['quality'] == 'adaptive':
             li.setProperty('inputstreamaddon', 'inputstream.adaptive')
             li.setProperty('inputstream', 'inputstream.adaptive')
             li.setProperty('inputstream.adaptive.manifest_type', 'hls')
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         xbmcutil.load_subtitles(stream['subs'])
Пример #3
0
 def play(self, item):
     stream = self.resolve(item['url'])
     if type(stream) == type([]):
         # resolved to mutliple files, we'll feed playlist and play the first one
         playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
         playlist.clear()
         for video in stream:
             li = xbmcgui.ListItem(label=video['title'], path=video['url'], iconImage='DefaultVideo.png')
             if video['subs'] != None and video['subs'] != '':
                 li.setSubtitles([video['subs']])
                 
             playlist.add(video['url'], li)
         stream = stream[0]
     if stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/play')
         if 'headers' in stream.keys():
             for header in stream['headers']:
                 stream['url'] += '|%s=%s' % (header, stream['headers'][header])
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'], iconImage='DefaulVideo.png')
         
         sub = False
         if xbmcaddon.Addon('xbmc.addon').getAddonInfo('version') > "16":
             sub = True
             if stream['subs'] != None and stream['subs'] != '':
                 li.setSubtitles([stream['subs']])
             
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         if sub == False:
             xbmcutil.load_subtitles(stream['subs'])
Пример #4
0
 def play(self,url):
     stream = self.resolve(url)
     if stream:
         xbmcutil.reportUsage(self.addon_id,self.addon_id+'/play')
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'],iconImage='DefaulVideo.png')
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         xbmcutil.load_subtitles(stream['subs'])
Пример #5
0
 def download(self,url,name):
     downloads = self.settings['downloads']
     if '' == downloads:
         xbmcgui.Dialog().ok(self.provider.name,xbmcutil.__lang__(30009))
         return
     stream = self.resolve(url)
     if stream:
         xbmcutil.reportUsage(self.addon_id,self.addon_id+'/download')
         if not stream['subs'] == '':
             util.save_to_file(stream['subs'],os.path.join(downloads,name+'.srt'))
         xbmcutil.download(self.addon,name,self.provider._url(stream['url']),os.path.join(downloads,name))
 def play(self, item):
     stream = self.resolve(item['url'])
     if stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/play')
         if 'headers' in stream.keys():
             headerStr = '|' + urllib.urlencode(stream['headers'])
             if len(headerStr) > 1:
                 stream['url'] += headerStr
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'], iconImage='DefaulVideo.png')
         il = self._extract_infolabels(item['info'])
         if len(il) > 0:  # only set when something was extracted
             li.setInfo('video', il)
         local_subs = xbmcutil.set_subtitles(li, stream['subs'], stream.get('headers'))
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
Пример #7
0
def play(url):
    stream, subs = resolve(url)
    if stream:
        xbmcutil.reportUsage(__scriptid__, __scriptid__ + "/play")
        print "Sending %s to player" % stream
        li = xbmcgui.ListItem(path=stream, iconImage="DefaulVideo.png")
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
        if not subs == "null":
            player = xbmc.Player()
            count = 0
            max_count = 99
            while not player.isPlaying() and count < max_count:
                xbmc.sleep(200)
                count += 1
                if count < max_count:
                    player.setSubtitles(subs)
 def play(self, item):
     stream = self.resolve(item['url'])[0]
     if stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/play')
         if 'headers' in stream.keys():
             for header in stream['headers']:
                 stream['url'] += '|%s=%s' % (header, stream['headers'][header])
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'], iconImage='DefaulVideo.png')
         sub = False
         if xbmcaddon.Addon('xbmc.addon').getAddonInfo('version') > "16":
             sub = True
             if stream['subs'] is not None and stream['subs'] != '':
                 li.setSubtitles([stream['subs']])
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         if sub == False:
             xbmcutil.load_subtitles(stream['subs'])
Пример #9
0
 def play(self,item):
     stream = self.resolve(item['url'])
     if stream:
         xbmcutil.reportUsage(self.addon_id,self.addon_id+'/play')
         if 'headers' in stream.keys():
             for header in stream['headers']:
                 stream['url'] += '|%s=%s' % (header,stream['headers'][header])
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'],iconImage='DefaulVideo.png')
         il = self._extract_infolabels(item['info'])
         if len(il) > 0: #only set when something was extracted
             li.setInfo('video',il)
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         if 'subs' in self.settings.keys():
             if self.settings['subs'] == True:
                 xbmcutil.load_subtitles(stream['subs'])
         else: # optional setting - plugin may not supply it
             xbmcutil.load_subtitles(stream['subs'])
Пример #10
0
 def download(self,item):
     downloads = self.settings['downloads']
     if '' == downloads:
         xbmcgui.Dialog().ok(self.provider.name,xbmcutil.__lang__(30009))
         return
     stream = self.resolve(item['url'])
     if stream:
         if not 'headers' in stream.keys():
             stream['headers'] = {}
         xbmcutil.reportUsage(self.addon_id,self.addon_id+'/download')
         # clean up \ and /
         name = item['title'].replace('/','_').replace('\\','_')
         if not stream['subs'] == '':
             util.save_to_file(stream['subs'],os.path.join(downloads,name+'.srt'))
         dot = name.find('.')
         if dot <= 0:
             # name does not contain extension, append some
             name+='.mp4'
         xbmcutil.download(self.addon,name,self.provider._url(stream['url']),os.path.join(downloads,name),headers=stream['headers'])
Пример #11
0
 def play(self, item):
     stream = self.resolve(item["url"])
     if type(stream) == type([]):
         # resolved to mutliple files, we'll feed playlist and play the first one
         playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
         playlist.clear()
         for video in stream:
             li = xbmcgui.ListItem(label=video["title"], path=video["url"], iconImage="DefaultVideo.png")
             playlist.add(video["url"], li)
         xbmc.Player().play(playlist)
     elif stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + "/play")
         if "headers" in stream.keys():
             for header in stream["headers"]:
                 stream["url"] += "|%s=%s" % (header, stream["headers"][header])
         print "Sending %s to player" % stream["url"]
         li = xbmcgui.ListItem(path=stream["url"], iconImage="DefaulVideo.png")
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         xbmcutil.load_subtitles(stream["subs"])
Пример #12
0
 def play(self, item):
     stream = self.resolve(item['url'])
     if type(stream) == type([]):
         # resolved to mutliple files, we'll feed playlist and play the first one
         playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
         playlist.clear()
         for video in stream:
             li = xbmcgui.ListItem(label=video['title'], path=video['url'], iconImage='DefaultVideo.png')
             playlist.add(video['url'], li)
         xbmc.Player().play(playlist)
     elif stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/play')
         if 'headers' in stream.keys():
             for header in stream['headers']:
                 stream['url'] += '|%s=%s' % (header, stream['headers'][header])
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'], iconImage='DefaulVideo.png')
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         xbmcutil.load_subtitles(stream['subs'])
Пример #13
0
 def play(self, url):
     stream = self.resolve(url)
     print type(stream)
     if type(stream) == type([]):
         # resolved to mutliple files, we'll feed playlist and play the first one
         playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
         playlist.clear()
         for video in stream:
             li = xbmcgui.ListItem(label=video['title'], path=video['url'], iconImage='DefaultVideo.png')
             playlist.add(video['url'], li)
         stream = stream[0]
     if stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/play')
         if 'headers' in stream.keys():
             for header in stream['headers']:
                 stream['url'] += '|%s=%s' % (header, stream['headers'][header])
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'], iconImage='DefaulVideo.png')
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         xbmcutil.load_subtitles(stream['subs'])
 def play(self, item):
     #xbmcplugin.setResolvedUrl(int(0), True, xbmcgui.ListItem(path='/dev/null'))
     stream = self.resolve(item['url'])
     if stream:
         xbmcutil.reportUsage(self.addon_id, self.addon_id + '/play')
         if 'headers' in stream.keys():
             headerStr = '|' + urllib.urlencode(stream['headers'])
             if len(headerStr) > 1:
                 stream['url'] += headerStr
         print 'Sending %s to player' % stream['url']
         li = xbmcgui.ListItem(path=stream['url'],
                               iconImage='DefaulVideo.png')
         il = self._extract_infolabels(item['info'])
         if len(il) > 0:  #only set when something was extracted
             li.setInfo('video', il)
         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
         if 'subs' in self.settings.keys():
             if self.settings['subs'] == True:
                 xbmcutil.load_subtitles(stream['subs'],
                                         stream.get('headers'))
         else:  # optional setting - plugin may not supply it
             xbmcutil.load_subtitles(stream['subs'], stream.get('headers'))
Пример #15
0
 def download(self,url,name):
     downloads = self.settings['downloads']
     if '' == downloads:
         xbmcgui.Dialog().ok(self.provider.name,xbmcutil.__lang__(30009))
         return
     stream = self.resolve(url)
     if stream:
         xbmcutil.reportUsage(self.addon_id,self.addon_id+'/download')
         if not stream['subs'] == '':
             util.save_to_file(stream['subs'],os.path.join(downloads,name+'.srt'))
         if stream['url'].find('munkvideo') > 0:
             # we have to handle this download a special way
             filename = xbmc.makeLegalFilename(os.path.join(downloads,name+'.mp4'))
             icon = os.path.join(__addon__.getAddonInfo('path'),'icon.png')
             output = open(filename,'wb')
             try:
                 req = urllib2.Request(stream['url'],headers={'Referer':'me'}) # that special way
                 response = urllib2.urlopen(req)
                 data = response.read(8192)
                 xbmc.executebuiltin('XBMC.Notification(%s,%s,3000,%s)' % (xbmc.getLocalizedString(13413).encode('utf-8'),filename,icon))
                 while len(data) > 0:
                     output.write(data)
                     data = response.read(8192)
                 response.close()
                 output.close()
                 if xbmc.Player().isPlaying():
                     xbmc.executebuiltin('XBMC.Notification(%s,%s,8000,%s)' % (xbmc.getLocalizedString(20177),filename,icon))
                 else:
                     xbmcgui.Dialog().ok(xbmc.getLocalizedString(20177),filename)
             except:
                 traceback.print_exc()
                 xbmc.executebuiltin('XBMC.Notification(%s,%s,5000,%s)' % (xbmc.getLocalizedString(257),filename,icon))
                 xbmcgui.Dialog().ok(filename,xbmc.getLocalizedString(257))
                 output.close()
         else:
             xbmcutil.download(self.addon,name,self.provider._url(stream['url']),os.path.join(downloads,name))