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'])
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 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'])
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))