コード例 #1
0
ファイル: utils.py プロジェクト: bialagary/mw
def download(name, url):
    my_addon = xbmcaddon.Addon()
    desty = my_addon.getSetting('downloads_folder')
    if not xbmcvfs.exists(desty):
        xbmcvfs.mkdir(desty)

    title = name
    name = re.sub('[^-a-zA-Z0-9_.() ]+', '', name)
    name = name.rstrip('.')
    ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:]
    if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg', 'mp3']: ext = 'mp4'
    filename = name + '.' + ext

    dest = os.path.join(desty, filename)
    new = my_addon.getSetting('new_downloader')
    if new == 'false':
        from lib.modules import commondownloader
        commondownloader.download(url, dest, 'Croatia On Demand')
    else:
        content = int(urllib.urlopen(url).info()['Content-Length'])
        size = 1024 * 1024
        mb = content / (1024 * 1024)
        if xbmcgui.Dialog().yesno('Croatia On Demand - Potvrda preuzimanja',
                                  filename, 'Veličina datoteke je %dMB' % mb,
                                  'Nastaviti s preuzimanjem?', 'Nastavi',
                                  'Prekini') == 1:
            return
        import SimpleDownloader as downloader
        downloader = downloader.SimpleDownloader()
        params = {"url": url, "download_path": desty, "Title": title}
        downloader.download(filename, params)
コード例 #2
0
def download(url, params):
	#episode = xbmc.getInfoLabel('ListItem.Episode')
	#season = xbmc.getInfoLabel('ListItem.Season')
	#show = xbmc.getInfoLabel('ListItem.TVShowTitle')
	#title = xbmc.getInfoLabel('ListItem.Title') 
	episode = params.get('episode')
	show = urllib.unquote_plus(params.get('show'))
	title = urllib.unquote_plus(params.get('title'))
	season = params.get('season')
	folder = downloadFolder + "/" + show + "/" + 'Season ' + params.get('season') + "/"
	content = getUrl("http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id="+url)
        match=re.compile('<url_flv><!\\[CDATA\\[(.+?)\\]\\]></url_flv>', re.DOTALL).findall(content)
	url = path=match[0]

	params = {"url": url, "download_path": folder, "Title": title}
	if len(str(episode)) < 2:
	    episode = '0'+episode
	if len(str(season)) < 2:
	    season = '0'+season
	filename = show + ".s" + season + ".e" + episode  + "." + title + ".mp4"

	if not os.path.exists(folder):
	    os.makedirs(folder)
        downloader.download(filename, params)
	return True
コード例 #3
0
ファイル: utils.py プロジェクト: corpusculus/kodi_serije
def download(name, url):
            my_addon = xbmcaddon.Addon()
            desty= my_addon.getSetting('downloads_folder')
            if not xbmcvfs.exists(desty):
                xbmcvfs.mkdir(desty)

            title=name
            name=re.sub('[^-a-zA-Z0-9_.() ]+', '', name)
            name=name.rstrip('.')
            ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:]
            if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg', 'mp3']: ext = 'mp4'
            filename = name + '.' + ext
      
            

            dest = os.path.join(desty, filename)
            new=my_addon.getSetting('new_downloader')
            if  new=='false':
                from lib.modules import commondownloader
                commondownloader.download(url, dest, 'Croatia On Demand')
            else:
                content = int(urllib.urlopen(url).info()['Content-Length'])
                size = 1024 * 1024
                mb   = content / (1024 * 1024)
                if xbmcgui.Dialog().yesno('Croatia On Demand - Potvrda preuzimanja', filename, 'Veličina datoteke je %dMB' % mb, 'Nastaviti s preuzimanjem?', 'Nastavi',  'Prekini') == 1:
                  return
                import SimpleDownloader as downloader
                downloader = downloader.SimpleDownloader()
                params = { "url": url, "download_path": desty, "Title": title }
                downloader.download(filename, params)
コード例 #4
0
ファイル: PVRdownload.py プロジェクト: 7fever/PSTV
def downloadFile(url, folder, name):
    print 'downloadFile'
    print url, folder
    download_folder = REAL_SETTINGS.getSetting("PVR_Folder")
    if download_folder == '':
        addon.show_small_popup(
            title='File Not Downloadable',
            msg='You need to set your download folder in addon settings first',
            delay=int(5000),
            image=THUMB)
    else:
        download_folder = os.path.join(download_folder, folder)
        if not os.path.exists(download_folder):
            os.makedirs(download_folder)
        # if resolvable(url):
        # url = resolve(url)
        # ext = ''
        # if '.mp4' in url:
        # ext = '.mp4'
        # elif '.flv' in url:
        # ext = '.flv'
        # elif '.avi' in url:
        # ext = '.avi'
        # if not ext == '':
        ext = '.mp4'
        params = {"url": url, "download_path": download_folder}
        downloader.download(name + ext, params)
コード例 #5
0
ファイル: download.py プロジェクト: bialagary/mw
def downloadFile(url):
    download_folder = settings.getSetting("download_folder")
    if download_folder == "":
        addon.show_small_popup(
            title="File Not Downloadable",
            msg="You need to set your download folder in addon settings first",
            delay=int(5000),
            image=thumb,
        )
    else:
        if resolvable(url):
            url = resolve(url)
            ext = ""
            if ".mp4" in url:
                ext = ".mp4"
            elif ".flv" in url:
                ext = ".flv"
            elif ".avi" in url:
                ext = ".avi"
            if not ext == "":
                if not os.path.exists(download_folder):
                    os.makedirs(download_folder)

                params = {"url": url, "download_path": download_folder}
                downloader.download(name + ext, params)
            else:
                addon.show_small_popup(
                    title="Can Not Download File", msg="Unsupported Host", delay=int(5000), image=thumb
                )
        else:
            addon.show_small_popup(
                title="Can Not Download File", msg="Unable To Resolve Url", delay=int(5000), image=thumb
            )
コード例 #6
0
def downloadFile(url):
    download_folder = settings.getSetting('download_folder')
    if download_folder == '':
        addon.show_small_popup(
            title='File Not Downloadable',
            msg='You need to set your download folder in addon settings first',
            delay=int(5000),
            image=thumb)
    else:
        if resolvable(url):
            url = resolve(url)
            ext = ''
            if '.mp4' in url:
                ext = '.mp4'
            elif '.flv' in url:
                ext = '.flv'
            elif '.avi' in url:
                ext = '.avi'
            if not ext == '':
                if not os.path.exists(download_folder):
                    os.makedirs(download_folder)

                params = {"url": url, "download_path": download_folder}
                downloader.download(name + ext, params)
            else:
                addon.show_small_popup(title='Can Not Download File',
                                       msg='Unsupported Host',
                                       delay=int(5000),
                                       image=thumb)
        else:
            addon.show_small_popup(title='Can Not Download File',
                                   msg='Unable To Resolve Url',
                                   delay=int(5000),
                                   image=thumb)
コード例 #7
0
ファイル: default.py プロジェクト: vphuc81/MyRepository
def download(url):
  #dialog = xbmcgui.Dialog()
  #download_path = dialog.browse(3, 'XBMC', 'files')
  
	if len(DOWNLOAD_PATH) == 0:
		
		alert('Cài đặt đường dẫn lưu trữ trong mục [COLOR red][B]Cấu hình[/B][/COLOR].')
		xbmcaddon.Addon(id='plugin.video.vietmediaF').openSettings('download_path')
	
	if len(DOWNLOAD_PATH) > 0:
		xbmc.log(url)
		data = fetch_data(url)
		if not data:
			return
		if data.get('error'):
			alert(data['error'])
			return
    
		if data.get("url"):
			link = data["url"]
			link = getlink.get(link)
			if link is None or len(link) == 0:
				notify('Lỗi không lấy được link phim hoặc server không hỗ trợ download.')
				return
			xbmcgui.Dialog().ok('VietmediaF', 'Bạn phải đặt tên files  cần lưu, và extention của file (có thể là "zip, mp4, mkv")', 'Ví dụ: [COLOR blue]video.mkv[/COLOR]')
			keyboard2 = xbmc.Keyboard()
			keyboard2.setHeading('SAVE FILE AS')
			keyboard2.doModal()
			if keyboard2.isConfirmed():
				file_name = keyboard2.getText()
			if len(file_name) == 0:
				return
				
			params = { "url": link, "download_path": DOWNLOAD_PATH }
			downloader.download(file_name, params)
コード例 #8
0
def download():
    nUrl, mirrorName = videoID(url)
    videoId = getHostedMediaFile(nUrl,mirrorName)
    mypath = makeDir()
    if mypath!='':
        downloadpath=mypath
    params = { "url": videoId, "download_path": downloadpath, "Title": name }
    downloader.download(str(name)+".mp4", params)
コード例 #9
0
def download():
    nUrl, mirrorName = videoID(url)
    videoId = getHostedMediaFile(nUrl, mirrorName)
    mypath = makeDir()
    if mypath != '':
        downloadpath = mypath
    params = {"url": videoId, "download_path": downloadpath, "Title": name}
    downloader.download(str(name) + ".mp4", params)
コード例 #10
0
def downloadVideo(item, downloadPath):
    if item.get_moving_data().has_key('videoStreamUrl'):
        import SimpleDownloader as downloader  # @UnresolvedImport
        downloader = downloader.SimpleDownloader()
        videoUrl = item.get_moving_data()['videoStreamUrl'].partition('|')[0]
        params = { "url": videoUrl, "download_path": downloadPath}
        downloader.download(item.get_xbmc_list_item_obj().getLabel(), params)
    else:
        displayDialogMessage("Download failure!", "Unable to resolve video URL.", "Please try again with different source.")
コード例 #11
0
def download_file(name, url):
        if addon.getSetting('save_location') == "":
            xbmc.executebuiltin("XBMC.Notification('LiveStreams','Choose a location to save files.',15000,"+icon+")")
            addon.openSettings()
        params = {'url': url, 'download_path': addon.getSetting('save_location')}
        downloader.download(name, params)
        dialog = xbmcgui.Dialog()
        ret = dialog.yesno('LiveStreams', 'Do you want to add this file as a source?')
        if ret:
            addSource(os.path.join(addon.getSetting('save_location'), name))
コード例 #12
0
ファイル: default.py プロジェクト: aladm/ShaniXBMCWork
def download_file(name, url):
        if addon.getSetting('save_location') == "":
            xbmc.executebuiltin("XBMC.Notification('LiveStreams','Choose a location to save files.',15000,"+icon+")")
            addon.openSettings()
        params = {'url': url, 'download_path': addon.getSetting('save_location')}
        downloader.download(name, params)
        dialog = xbmcgui.Dialog()
        ret = dialog.yesno('LiveStreams', 'Do you want to add this file as a source?')
        if ret:
            addSource(os.path.join(addon.getSetting('save_location'), name))
コード例 #13
0
def downloadVideo(item, downloadPath):
    if item.get_moving_data().has_key('videoStreamUrl'):
        import SimpleDownloader as downloader  # @UnresolvedImport
        downloader = downloader.SimpleDownloader()
        videoUrl = item.get_moving_data()['videoStreamUrl'].partition('|')[0]
        params = {"url": videoUrl, "download_path": downloadPath}
        downloader.download(item.get_xbmc_list_item_obj().getLabel(), params)
    else:
        displayDialogMessage("Download failure!",
                             "Unable to resolve video URL.",
                             "Please try again with different source.")
コード例 #14
0
ファイル: chiasenhac.py プロジェクト: cuongnvth/hieuhien.vn
def download(url):
    try:
        url=medialink(url)
        filename = str(re.compile('[a-zA-Z0-9-_%]+\.\w+$').findall(url)[0])
        filename= urllib2.unquote(filename).replace(' ','').replace('-','')
        params = {"url": url, "download_path": downloadpath, "Title": '[COLOR ffff0000]'+filename+'[/COLOR]'}
        if os.path.isfile(downloadpath+filename):
            dialog = xbmcgui.Dialog()
            if dialog.yesno('Download message','File exists! re-download?'):
                downloader.download(filename, params)
        else:
            downloader.download(filename, params)
    except:pass
コード例 #15
0
def download(url):
    try:
        filename = re.compile('[a-zA-Z0-9-_]+\.\w+$').findall(url)[0]
        filetype = re.compile('\.\w+$').findall(url)[0]
        title_num = re.compile('(?:-|_|\+)\w*\.\w+$').findall(filename)[0]
        title = str(filename).replace(title_num,'')
        filename = title+filetype
        params = {"url": url, "download_path": downloadpath, "Title": title}
        if os.path.isfile(downloadpath+filename):
            dialog = xbmcgui.Dialog()
            if dialog.yesno('Download message','File exists! re-download?'):
                downloader.download(filename, params)
        else:
            downloader.download(filename, params)
    except:pass
コード例 #16
0
def download(url):
    try:
        filename = re.compile('[a-zA-Z0-9-_]+\.\w+$').findall(url)[0]
        filetype = re.compile('\.\w+$').findall(url)[0]
        title_num = re.compile('(?:-|_|\+)\w*\.\w+$').findall(filename)[0]
        title = str(filename).replace(title_num,'')
        filename = title+filetype
        params = {"url": url, "download_path": downloadpath, "Title": title}
        if os.path.isfile(downloadpath+filename):
            dialog = xbmcgui.Dialog()
            if dialog.yesno('Download message','File exists! re-download?'):
                downloader.download(filename, params)
        else:
            downloader.download(filename, params)
    except:pass
コード例 #17
0
def downloadLiveLeakVideo(id):
    downloader = SimpleDownloader.SimpleDownloader()
    content = opener.open("http://www.liveleak.com/view?i=" + id).read()
    match = re.compile('<title>LiveLeak.com - (.+?)</title>',
                       re.DOTALL).findall(content)
    global ll_downDir
    while not ll_downDir:
        xbmc.executebuiltin('XBMC.Notification(Download:,Liveleak ' +
                            translation(30186) + '!,5000)')
        addon.openSettings()
        ll_downDir = addon.getSetting("ll_downDir")
    url = getLiveLeakStreamUrl(id)
    filename = ""
    try:
        filename = (''.join(c for c in unicode(match[0], 'utf-8')
                            if c not in '/\\:?"*|<>')).strip()
    except:
        filename = id
    filename += ".mp4"
    if not os.path.exists(os.path.join(ll_downDir, filename)):
        params = {"url": url, "download_path": ll_downDir}
        downloader.download(filename, params)
    else:
        xbmc.executebuiltin('XBMC.Notification(Download:,' +
                            translation(30185) + '!,5000)')
コード例 #18
0
def download(url, name):
    dialog = xbmcgui.Dialog()

    url  = resolveUrl(url)
    endung = re.search('\.([^\.]*)$', url)
    name = re.sub('[^0-9a-zA-Z:\. -]','',name)
    name = (name + datetime.datetime.now().isoformat(' ') + "." + endung.group(1))

    xbmc.log("Download start: " + url + ", " + name)

    download_path = addon.getSetting("download")
    if download_path == "":
        dialog.ok("Error", "You have to set download dir")
    else:
        args = { "url": url, "download_path": download_path }
        downloader.download(name, args)
コード例 #19
0
def download_file(url, title):
    path = addon.getSetting('download')
    if path == "":
        xbmc.executebuiltin("XBMC.Notification(%s,%s,10000,%s)"
                %(language(30000), language(30010), icon))
        addon.openSettings()
        path = addon.getSetting('download')
    if path == "":
        return
    addon_log('######### Download #############')
    file_downloader = downloader.SimpleDownloader()
    if ' - ' in title:
        title = title.split(' - ', 1)[1]
    invalid_chars = ['>', '<', '*', '/', '\\', '?', '.']
    for i in invalid_chars:
        title = title.replace(i, '')
    name = title.replace(' ', '_')
    name += url.rsplit('/', 1)[1]
    if not '.' in name:
        if 'zip' in name.lower():
            name += '.zip'
        elif 'm3u' in name.lower():
            name += '.m3u'
        elif 'whole_directory' in name.lower():
            name += '.zip'

    params = {"url": url, "download_path": path, "Title": title}
    addon_log(str(params))
    file_downloader.download(name, params)
    addon_log('################################')
コード例 #20
0
def download_video(source, url):
    import SimpleDownloader
    sd = SimpleDownloader.SimpleDownloader()
    playable_url = _get_playable_url(source, url)
    if source == 'apple.com':
        sd.common.USERAGENT = 'QuickTime'
        playable_url = playable_url.split('|')[0]
    elif source == 'youtube.com':
        plugin.notify(msg=_('download_not_possible'))
        return
    download_path = plugin.get_setting('download_path')
    while not download_path:
        try_again = xbmcgui.Dialog().yesno(_('no_download_path'),
                                           _('want_set_now'))
        if not try_again:
            return
        plugin.open_settings()
        download_path = plugin.get_setting('download_path')
    filename = playable_url.split('?')[0].split('/')[-1]
    if filename == 'makeplaylist.dll':
        filename = playable_url.split('=')[-1]  # yahoo...
    params = {'url': playable_url, 'download_path': download_path}
    sd.download(filename, params)
    downloads = plugin.get_storage('downloads')
    downloads[url] = xbmc.translatePath(download_path + filename)
    downloads.sync()
コード例 #21
0
ファイル: default.py プロジェクト: donam/koditv.store
def download(url):
    try:
        VideoUrl = medialink(url)

        if VideoUrl.find('youtube')==-1:
            filename = gname+'.mp4'
            print 'Start downloading '+filename
            print VideoUrl
            params = {"url": VideoUrl, "download_path": downloadpath, "Title": gname}
            if os.path.isfile(downloadpath+filename):
                dialog = xbmcgui.Dialog()
                if dialog.yesno('Download message','File exists! re-download?'):
                    downloader.download(filename, params)
            else:
                downloader.download(filename, params)

    except:pass
コード例 #22
0
def download(artist, track):
    data = getTrack(artist, track)
    loader = downloader.SimpleDownloader()
    params = {
        'url': data['url'],
        'download_path': plugin.get_setting('Download Path')
    }
    loader.download('%s - %s.mp3' % (artist, track), params)
コード例 #23
0
def get_video(url, name, plot, studio, episode, thumb, date):
	if '{' in url:
		url = ast.literal_eval(url)
		try:
			path = url[settings.getSetting('format').lower().replace('hd','hd720p30').replace('high','large').replace('low','small')]['url']
		except:
			if 'hd' in url:
				path = url['hd']['url']
			elif 'large' in url:
				path = url['large']['url']
			elif 'small' in url:
				path = url['small']['url']
			else:
				path = url.items()[0][1]['url']
	else:
		oembed = getUrl('http://revision3.com/api/oembed/?url=http://revision3.com/%s/&format=json' % url)
		video_id = re.compile('html5player\-v(.+?)\?external').findall(oembed)[0]
		api = getUrl('http://revision3.com/api/flash?video_id=' + video_id)
		videos_api = common.parseDOM(api, "media", ret = "type")
		videos_api[:] = (value for value in videos_api if value != 'thumbnail')
		durl = {}
		for type_api in videos_api:
			content_api = clean(common.parseDOM(api, "media", attrs = { "type": type_api })[0])
			durl[type_api] = content_api
		try:
			path = durl[settings.getSetting('format').lower()]
		except:
			if 'high' in durl:
				path = durl['high']
			elif 'low' in durl:
				path = durl['low']
			else:
				path = str(durl.items()[0][1])
	if settings.getSetting('download') == 'true':
		while not settings.getSetting('downloadPath'):
			if settings.getSetting('download') == 'false':
				xbmc.executebuiltin("Container.Refresh")
				return
			dialog = xbmcgui.Dialog()
			ok = dialog.ok(plugin, settings.getLocalizedString( 30011 ))
			settings.openSettings()
		params = { "url": path, "download_path": settings.getSetting('downloadPath'), "Title": name }
		downloader.download(clean_file(name) + '.' + path.split('/')[-1].split('.')[-1], params)
	else:
		infoLabels = { "Title": name, "Studio": 'Revision3: ' + studio, "Plot": plot, "Episode": int(episode), "Aired": date  }
		playListItem(label = name, image = thumb, path = path, infoLabels = infoLabels, PlayPath = False)
コード例 #24
0
def download(params):
    fileUrl = client.get_full_url(urllib.unquote_plus(params['file_url']))
    fileName = fileUrl.split('/')[-1]
    download_params = {
        'url': fileUrl,
        'download_path': __settings__.getSetting('Download Path')
    }
    client = downloader.SimpleDownloader()
    client.download(fileName, download_params)
コード例 #25
0
ファイル: chiasenhac.py プロジェクト: AquariusIV/fptplaynet
def download(url):
    try:
        url = medialink(url)
        filename = str(re.compile('[a-zA-Z0-9-_%]+\.\w+$').findall(url)[0])
        filename = urllib2.unquote(filename).replace(' ', '').replace('-', '')
        params = {
            "url": url,
            "download_path": downloadpath,
            "Title": '[COLOR ffff0000]' + filename + '[/COLOR]'
        }
        if os.path.isfile(downloadpath + filename):
            dialog = xbmcgui.Dialog()
            if dialog.yesno('Download message', 'File exists! re-download?'):
                downloader.download(filename, params)
        else:
            downloader.download(filename, params)
    except:
        pass
コード例 #26
0
 def downloadVideo(self, video):
     ok = True    
     try:
         my_downloader = downloader.SimpleDownloader()
         params = {"videoid": "1", "video_url": video[self.PARAM_VIDEO_ID], "Title": video[self.PARAM_VIDEO_NAME]}
         my_downloader.downloadVideo(params)            
         
     except Exception,msg:
         print_exc("Error downloadVideo : %s", msg)
         xbmc.executebuiltin("XBMC.Notification(%s,%s)"%("ERROR downloadVideo ",msg))  
コード例 #27
0
ファイル: addon.py プロジェクト: crazydenix/mnn-xbmc-repo
def download(params):
    dir = addon.getSetting('DownloadDir')
    if not os.path.exists(dir):
        xbmcMessage('Неверный путь для загрузки', 7000)

    url = site_url + urllib.unquote(params['href'])
    name = urllib.unquote_plus(params['title'])

    dl = downloader.SimpleDownloader()
    dl.download(name.decode('UTF-8'), {'url': url, 'download_path': dir})
コード例 #28
0
ファイル: gozlan.py プロジェクト: yossimav123/XbmcAddons
def gozlan_download(url, params):
    engname=params["engname"]
    imdbref=params["imdbref"]
    #print "params="+str(params)
    # xbmcgui.Dialog().ok("Params" , str(params))
    if (url.find('http')<0):
            url = base_domain+"/"+url
    page=getData(url,7)
    # <iframe src="http://www.putlocker.com/embed/F4988CE321910D0D" id='iframeinner'
    regexp='<iframe src="(.*?)" id=\'iframeinner\''
    media_url=re.compile(regexp,re.M+re.I+re.S).findall(page)[0]
    #print "Resolving URL: " + media_url
    videoPlayListUrl = gozlanurlresolver.HostedMediaFile(url=media_url).resolve()
    if not videoPlayListUrl:
      print "URL " + media_url + " could not have been resolved to a movie.\n"
      return
    #addon.resolve_url(stream_url)
    #videoPlayListUrl = urllib.unquote(videoUrl[0])
    #print "video url " + videoPlayListUrl

    vurl = videoPlayListUrl #videoPlayListUrl[1:videoPlayListUrl.find('|')]
    movie_name = engname
    dwldPath = xbmc.translatePath(os.path.join(__BASE_MOVIES_PATH__, "%s"%(movie_name)))
    if not os.path.exists(dwldPath):
        os.makedirs(dwldPath)
    if (vurl.find(".flv") > 0):
        filename = engname + ".flv"
    elif (vurl.find(".mp4") > 0):
        filename = engname + ".mp4"
    else :
        filename = engname+".avi"

    # Save nfo file
    if len(imdbref) > 1:
        text_file = open(dwldPath+'\\'+engname+".nfo", "w")
        text_file.write(imdbref)
        text_file.close()
    
    prms = { "url": vurl, "download_path": dwldPath, "Title": movie_name }
    print "downloading %s from %s to %s"%(movie_name, vurl,dwldPath+'\\'+engname)
    # downloader.dbg = True
    downloader.download(filename, prms)
コード例 #29
0
    def intializePlugin(self):
        import cookielib
        import urllib2
        sys.modules["__main__"].cookiejar = cookielib.LWPCookieJar()
        sys.modules["__main__"].opener = urllib2.build_opener(
            urllib2.HTTPCookieProcessor(sys.modules["__main__"].cookiejar))
        urllib2.install_opener(sys.modules["__main__"].opener)

        sys.argv = ["something", -1, "something_else"]
        import CommonFunctions
        reload(CommonFunctions)
        sys.modules["__main__"].common = CommonFunctions
        sys.modules["__main__"].common.log = sys.modules["__main__"].xbmc.log
        sys.modules["__main__"].settingsDL.load_strings(
            "./resources/settings.xml")
        sys.modules["__main__"].xbmcaddon.Addon.return_value = sys.modules[
            "__main__"].settingsDL
        sys.modules["__main__"].xbmcvfs.exists.return_value = True

        import SimpleDownloader
        sys.modules["__main__"].downloader = SimpleDownloader.SimpleDownloader(
        )
        sys.modules["__main__"].xbmcvfs.exists.return_value = False
        import YouTubePluginSettings
        sys.modules[
            "__main__"].pluginsettings = YouTubePluginSettings.YouTubePluginSettings(
            )
        import YouTubeUtils
        sys.modules["__main__"].utils = YouTubeUtils.YouTubeUtils()
        import YouTubeStorage
        sys.modules["__main__"].storage = YouTubeStorage.YouTubeStorage()
        import YouTubeCore
        sys.modules["__main__"].core = YouTubeCore.YouTubeCore()
        sys.modules["__main__"].core.getVideoIdStatusFromCache = Mock()
        sys.modules[
            "__main__"].core.getVideoIdStatusFromCache.return_value = []
        import YouTubeLogin
        sys.modules["__main__"].login = YouTubeLogin.YouTubeLogin()
        import YouTubeFeeds
        sys.modules["__main__"].feeds = YouTubeFeeds.YouTubeFeeds()
        import YouTubeSubtitleControl
        sys.modules[
            "__main__"].subtitles = YouTubeSubtitleControl.YouTubeSubtitleControl(
            )
        import YouTubePlayer
        sys.modules["__main__"].player = YouTubePlayer.YouTubePlayer()
        import YouTubeScraper
        sys.modules["__main__"].scraper = YouTubeScraper.YouTubeScraper()
        import YouTubePlaylistControl
        sys.modules[
            "__main__"].playlist = YouTubePlaylistControl.YouTubePlaylistControl(
            )
        import YouTubeNavigation
        self.navigation = YouTubeNavigation.YouTubeNavigation()
コード例 #30
0
ファイル: sdarottv.py プロジェクト: olegil/xbmc-israel
def download_season(url):
    import SimpleDownloader as downloader
    downloader = downloader.SimpleDownloader()
    downloader.dbg = False
    
    series_id=urllib.unquote_plus(params["series_id"])
   
    season_id=urllib.unquote_plus(params["season_id"])
    
   
    page = getData(url=DOMAIN+"/ajax/watch",timeout=0,postData="episodeList=true&serie="+series_id+"&season="+season_id);
    
    episodes=json.loads(page)
    if episodes is None or (len(episodes)==0):
        xbmcgui.Dialog().ok('Error occurred',"לא נמצאו פרקים לעונה")
        return
    print "Download sdarot series=" + series_id + " season=" + season_id + " #episodes=" + str(len(episodes))
    for i in range (0, len(episodes)) :
        epis= str(episodes[i]['episode'])
        finalVideoUrl,VID = getFinalVideoUrl(series_id,season_id,epis,silent=True)
        if finalVideoUrl == None :
            continue
        
        print "Downloading:" + str(finalVideoUrl)
        fileName = 'S' + str(season_id).zfill(2) + 'E' + str(epis).zfill(2) + '_' + str(VID) + '.mp4'
        download_path = os.path.join(path,str(series_id))
        if not os.path.exists(download_path):
            os.makedirs(download_path) 
        
        finalFileName = os.path.join(download_path,fileName)
        if not os.path.isfile(finalFileName):
            #progress = xbmcgui . DialogProgress ( )
            #progress.create ( "XBMC ISRAEL" , "Downloading " , '' , 'Please Wait' )
        
            try :
               #downloader . download ( finalVideoUrl , download_path , progress )
               downloaderParams = { "url": finalVideoUrl, "download_path": download_path }
               downloader.download(fileName, downloaderParams,async=True)
            except Exception, e:
                print str(e)
                pass
コード例 #31
0
ファイル: addonfunc.py プロジェクト: camster1/RTOTV
def start_download(name, path):
    try:
        ext = splitext(basename(urlparse(path).path))[1]
    except:
        ext = '.mp4'
    dialog = xbmcgui.Dialog()
    #dir = dialog.browse(0, settings.getLocalizedString( 30059 ), 'files', '', False, False, settings.getSetting('downloadPath'))
    if settings.getSetting('downloadPrompt') == 'true':
        dir = dialog.browse(0, settings.getLocalizedString(30059), 'files')
    else:
        while not settings.getSetting('downloadPath'):
            ok = dialog.ok(plugin, settings.getLocalizedString(30058))
            settings.openSettings()
            if settings.getSetting('downloadPrompt') == 'true':
                dir = dialog.browse(0, 'XBMC', 'files')
                settings.setSetting('downloadPath', dir)
        dir = settings.getSetting('downloadPath')
    if len(dir) == 0:
        return
    params = {"url": path, "download_path": dir, "Title": name}
    downloader.download(clean_file(name) + ext, params)
コード例 #32
0
def start_download(name, path):
	try:
		ext = splitext(basename(urlparse(path).path))[1]
	except:
		ext = '.mp4'
	dialog = xbmcgui.Dialog()
	#dir = dialog.browse(0, settings.getLocalizedString( 30059 ), 'files', '', False, False, settings.getSetting('downloadPath'))
	if settings.getSetting('downloadPrompt') == 'true':
		dir = dialog.browse(0, settings.getLocalizedString( 30059 ), 'files')
	else:
		while not settings.getSetting('downloadPath'):
			ok = dialog.ok(plugin, settings.getLocalizedString( 30058 ))
			settings.openSettings()
			if settings.getSetting('downloadPrompt') == 'true':
				dir = dialog.browse(0, 'XBMC', 'files')
				settings.setSetting('downloadPath', dir)
		dir = settings.getSetting('downloadPath')
	if len(dir) == 0:
		return
	params = { "url": path, "download_path": dir, "Title": name }
	downloader.download(clean_file(name) + ext, params)
コード例 #33
0
def download_season(url):
    import SimpleDownloader as downloader
    downloader = downloader.SimpleDownloader()
    downloader.dbg = False

    series_id = urllib.unquote_plus(params["series_id"])

    season_id = urllib.unquote_plus(params["season_id"])

    page = getData(url=DOMAIN + "/ajax/watch",
                   timeout=0,
                   postData="episodeList=true&serie=" + series_id +
                   "&season=" + season_id)

    episodes = json.loads(page)
    if episodes is None or (len(episodes) == 0):
        xbmcgui.Dialog().ok('Error occurred', "לא נמצאו פרקים לעונה")
        return
    print "Download sdarot series=" + series_id + " season=" + season_id + " #episodes=" + str(
        len(episodes))
    for i in range(0, len(episodes)):
        epis = str(episodes[i]['episode'])
        finalVideoUrl, VID = getFinalVideoUrl(series_id,
                                              season_id,
                                              epis,
                                              url,
                                              silent=True)
        if finalVideoUrl == None:
            continue

        print "Downloading:" + str(finalVideoUrl)
        fileName = 'S' + str(season_id).zfill(2) + 'E' + str(epis).zfill(
            2) + '_' + str(VID) + '.mp4'
        download_path = os.path.join(path, str(series_id))
        if not os.path.exists(download_path):
            os.makedirs(download_path)

        finalFileName = os.path.join(download_path, fileName)
        if not os.path.isfile(finalFileName):
            #progress = xbmcgui . DialogProgress ( )
            #progress.create ( "XBMC ISRAEL" , "Downloading " , '' , 'Please Wait' )

            try:
                #downloader . download ( finalVideoUrl , download_path , progress )
                downloaderParams = {
                    "url": finalVideoUrl,
                    "download_path": download_path
                }
                downloader.download(fileName, downloaderParams, async=True)
            except Exception, e:
                print str(e)
                pass
コード例 #34
0
ファイル: PVRdownload.py プロジェクト: 1c0n/XBMC_Addons
def downloadFile(url, folder, name):
    print 'downloadFile'
    print url, folder
    download_folder = REAL_SETTINGS.getSetting("PVR_Folder")
    if download_folder == '':
        addon.show_small_popup(title='File Not Downloadable', msg='You need to set your download folder in addon settings first', delay=int(5000), image=THUMB)
    else:     
        download_folder = os.path.join(download_folder, folder)
        if not os.path.exists(download_folder):
             os.makedirs(download_folder)
        # if resolvable(url):
            # url = resolve(url)
            # ext = ''
            # if '.mp4' in url:
                # ext = '.mp4'
            # elif '.flv' in url:
                # ext = '.flv'
            # elif '.avi' in url:
                # ext = '.avi'
            # if not ext == '':
        ext = '.mp4'
        params = {"url":url, "download_path":download_folder}
        downloader.download(name + ext, params)
コード例 #35
0
def downloadVideo(url, title):
    valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
    video_url, subtitles = scrapVideo(url)
    params = {}
    params["url"] = video_url
    downloadPath = yleAreenaAddon.addon.getSetting('download-path')
    if downloadPath == None or downloadPath == '':
        return
    params["download_path"] = downloadPath

    filename = "%s.mp4" % (''.join(c for c in title if c in valid_chars))
    #filename = 'test.mp4'
    xbmc.log(filename + "  " + str(params))
    dw = downloader.SimpleDownloader()
    dw.download(filename, params)
コード例 #36
0
ファイル: download.py プロジェクト: nek0316/Repo
def downloadFile(url):
     download_folder = settings.getSetting('download_folder')
     if download_folder == '':
          addon.show_small_popup(title='File Not Downloadable', msg='You need to set your download folder in addon settings first', delay=int(5000), image=thumb)
     else:     
          if resolvable(url):
               url = resolve(url)
               ext = ''
               if '.mp4' in url:
                    ext = '.mp4'
               elif '.flv' in url:
                    ext = '.flv'
               elif '.avi' in url:
                    ext = '.avi'
               if not ext == '':
                    if not os.path.exists(download_folder):
                         os.makedirs(download_folder)

                    params = {"url":url, "download_path":download_folder}
                    downloader.download(name + ext, params)
               else:
                    addon.show_small_popup(title='Can Not Download File', msg='Unsupported Host', delay=int(5000), image=thumb)
          else:
               addon.show_small_popup(title='Can Not Download File', msg='Unable To Resolve Url', delay=int(5000), image=thumb)
コード例 #37
0
    def initializePlugin(self):
        import CommonFunctions
        sys.modules["__main__"].common = CommonFunctions
        sys.modules["__main__"].common.log = sys.modules["__main__"].xbmc.log
        sys.modules["__main__"].xbmcaddon.Addon.return_value = sys.modules[
            "__main__"].settings
        sys.modules["__main__"].xbmcvfs.exists.return_value = True

        import SimpleDownloader
        sys.modules["__main__"].downloader = SimpleDownloader.SimpleDownloader(
        )

        import cookielib
        import urllib2
        sys.modules["__main__"].cookiejar = cookielib.LWPCookieJar()
        opener = urllib2.build_opener(
            urllib2.HTTPCookieProcessor(sys.modules["__main__"].cookiejar))
        urllib2.install_opener(opener)

        sys.argv = ["something", -1, "something_else"]

        import VimeoUtils
        sys.modules["__main__"].utils = VimeoUtils.VimeoUtils()

        import VimeoLogin
        sys.modules["__main__"].login = VimeoLogin.VimeoLogin()

        import VimeoCore
        sys.modules["__main__"].core = VimeoCore.VimeoCore()

        import VimeoStorage
        sys.modules["__main__"].storage = VimeoStorage.VimeoStorage()

        import VimeoFeeds
        sys.modules["__main__"].feeds = VimeoFeeds.VimeoFeeds()

        import VimeoPlayer
        sys.modules["__main__"].player = VimeoPlayer.VimeoPlayer()

        import VimeoPlaylistControl
        sys.modules[
            "__main__"].playlist = VimeoPlaylistControl.VimeoPlaylistControl()

        import VimeoNavigation
        self.navigation = VimeoNavigation.VimeoNavigation()
コード例 #38
0
ファイル: ruutu.py プロジェクト: dor57/xbmc-finnish-tv
def downloadVideo(url, title):
    valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
    videoUrl = scrapVideoLink(url)

    downloadPath = ruutu.addon.getSetting('download-path')
    if downloadPath is None or downloadPath == '':
        return
    downloadPath += url.split('/')[-2]
    if not os.path.exists(downloadPath):
        os.makedirs(downloadPath)

    filename = "%s %s" % (''.join(
        c for c in title if c in valid_chars), videoUrl.split(':')[-1])

    params = {"url": videoUrl, "download_path": downloadPath}
    xbmc.log(url + " " + filename + "   " + str(params))
    dw = downloader.SimpleDownloader()
    dw.download(filename, params)
コード例 #39
0
def download_trailer(local_path, remote_url, trailer_id):
     # if remote_url is None, trailer is already downloaded, do nothing
    if not remote_url:
        return
    sd = SimpleDownloader.SimpleDownloader()
    if '?|User-Agent=' in remote_url:
        remote_url, useragent = remote_url.split('?|User-Agent=')
        # Override User-Agent because SimpleDownloader doesn't support that
        # native. Downloading from apple requires QT User-Agent
        sd.common.USERAGENT = useragent
    download_path, filename = os.path.split(local_path)
    params = {'url': remote_url,
              'download_path': download_path}
    # start the download in background
    sd.download(filename, params)
    # set the setting - if the download is not finished but playback is tried,
    # the check isfile will fail and it won't be there before finish
    plugin.set_setting(trailer_id, local_path)
    __log('start downloading: %s to path: %s' % (filename, download_path))
コード例 #40
0
    def downloadVideo(self, video):
        ok = True

        my_downloader = downloader.SimpleDownloader()
        try:
            if my_downloader.isRTMPInstalled():
                url = video[self.PARAM_VIDEO_ID]

                if isinstance(self.PARSER, LiveParser):
                    hd, params = self.PARSER.decode_link(hd)

                    params["download_path"] = self.DOWNLOADDIR
                    params["Title"] = video[self.PARAM_VIDEO_NAME]
                    params["use_rtmpdump"] = True

                else:
                    params = {
                        "url": url,
                        "download_path": self.DOWNLOADDIR,
                        "Title": video[self.PARAM_VIDEO_NAME]
                    }

                name = "%s.mp4" % (video[self.PARAM_VIDEO_NAME])
                my_downloader.download(name, params, False)

            else:
                print("You must install rtmpdump")
                xbmc.executebuiltin(
                    "XBMC.Notification(%s,%s)" %
                    ("ERROR downloadVideo", "You must install rtmpdump"))

        except Exception, msg:
            print("Error downloadVideo : %s", msg)
            print_exc()
            item = my_downloader._getNextItemFromQueue()

            if item is not None:
                (item_id, item) = item
                my_downloader._removeItemFromQueue(item_id)

            xbmc.executebuiltin("XBMC.Notification(%s,%s)" %
                                ("ERROR downloadVideo", msg))
コード例 #41
0
def downloadVideo(id):
    downloader = SimpleDownloader.SimpleDownloader()
    content = getUrl2("http://www.dailymotion.com/embed/video/"+id)
    match = re.compile('<title>(.+?)</title>', re.DOTALL).findall(content)
    global downloadDir
    if not downloadDir:
        xbmc.executebuiltin('XBMC.Notification(Download:,'+translation(30110)+'!,5000)')
        return    
    url = getStreamUrl(id)
    filename = ""
    try:
        filename = (''.join(c for c in unicode(match[0], 'utf-8') if c not in '/\\:?"*|<>')).strip()
    except:
        filename = id
    filename+=".mp4"
    if not os.path.exists(os.path.join(downloadDir, filename)):
        params = { "url": url, "download_path": downloadDir }
        downloader.download(filename, params)
    else:
        xbmc.executebuiltin('XBMC.Notification(Download:,'+translation(30109)+'!,5000)')
コード例 #42
0
def downloadImage(url, title):
    downloader = SimpleDownloader.SimpleDownloader()
    global downDir
    while not downDir:
        xbmc.executebuiltin('XBMC.Notification(Download:,' +
                            translation(30186) + '!,5000)')
        addon.openSettings()
        downDir = addon.getSetting("downDir")
    try:
        filename = (''.join(
            c for c in unicode(title, 'utf-8')
            if c not in '/\\:?"*|<>')).strip() + "." + url.split(".")[-1]
    except:
        filename = url.split("/")[-1]
    if not os.path.exists(os.path.join(downDir, filename)):
        params = {"url": url, "download_path": downDir}
        downloader.download(filename, params)
    else:
        xbmc.executebuiltin('XBMC.Notification(Download:,' +
                            translation(30185) + '!,5000)')
コード例 #43
0
def download_file(stream_url, title):
    """ thanks/credit to TheCollective for SimpleDownloader module"""
    path = addon.getSetting('download')
    if path == "":
        xbmc.executebuiltin("Notification(%s,%s,10000,%s)"
                            % (language(30038), language(30037), addon_icon))
        addon.openSettings()
        path = addon.getSetting('download')
    if path == "":
        return
    addon_log('######### Download #############')
    file_downloader = Downloader.SimpleDownloader()
    invalid_chars = ['>', '<', '*', '/', '\\', '?', '.']
    for i in invalid_chars:
        title = title.replace(i, '')
    name = '%s.%s' % (title.replace(' ', '_'), stream_url.split('.')[-1])
    addon_log('Title: %s - Name: %s' % (title, name))
    download_params = {"url": stream_url, "download_path": path, "Title": title}
    addon_log(str(download_params))
    file_downloader.download(name, download_params)
    addon_log('################################')
コード例 #44
0
def download_trailer(download_url, play_url):
    import SimpleDownloader
    sd = SimpleDownloader.SimpleDownloader()
    sd.common.USERAGENT = USER_AGENT
    download_path = plugin.get_setting('trailer_download_path')
    while not download_path:
        try_again = xbmcgui.Dialog().yesno(
            _('no_download_path'),
            _('want_set_now')
        )
        if not try_again:
            return
        plugin.open_settings()
        download_path = plugin.get_setting('trailer_download_path')
    filename = download_url.split('/')[-1]
    params = {
        'url': download_url,
        'download_path': download_path
    }
    sd.download(filename, params)
    downloads = plugin.get_storage('downloads')
    downloads[play_url] = xbmc.translatePath(download_path + filename)
    downloads.sync()
コード例 #45
0
	if mode == 'downloadVideo':

		# Ask where to save the file
		downloadLocationDialog = xbmcgui.Dialog()
		downloadLocation = downloadLocationDialog.browse(3, 'Download Location', 'files')

		params = {
					'url':__urlDecode(downloadUrl),
					'download_path':downloadLocation,
					'Title':downloadTitle
				}

		print 'Download Parameters: %s' % params
		print 'Download Filename: %s.mp4' % downloadTitle
		downloader.download('%s.mp4' % downloadTitle, params)
	else:
		if mode is None:
			index = 0
			for item in playlists:
				print('Added Folder [{0}|{1}]'.format(item['title'],index))
				url = __urlEncode({'mode':'folder','foldername':item['title'],'playlistId':index})
				li = xbmcgui.ListItem(label=item['title'], iconImage=icon, thumbnailImage=icon)
				xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
				index+=1
		elif mode == 'folder':
			for item in playlists[int(playlistId)]['lists']:
				print('Added Folder [{0}]'.format(item['id']))
				url = __urlEncode({'mode':'section','foldername':item['title'],'playlistId':item['id']})
				li = xbmcgui.ListItem(label=item['title'], iconImage=icon, thumbnailImage=icon)
				xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
コード例 #46
0
ADDON_NAME = addon.getAddonInfo('name')
REAL_SETTINGS = xbmcaddon.Addon(id=addnon_id)
ADDON_SETTINGS = REAL_SETTINGS.getAddonInfo('profile')
MediaList_LOC = xbmc.translatePath(os.path.join(ADDON_SETTINGS,'MediaList.xml'))
STRM_LOC = xbmc.translatePath(os.path.join(ADDON_SETTINGS,'STRM_LOC'))
profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
home = xbmc.translatePath(addon.getAddonInfo('path').decode('utf-8'))
favorites = os.path.join(profile, 'favorites')
history = os.path.join(profile, 'history')
dialog = xbmcgui.Dialog()
icon = os.path.join(home, 'icon.png')
iconRemove = os.path.join(home, 'iconRemove.png')
FANART = os.path.join(home, 'fanart.jpg')
source_file = os.path.join(home, 'source_file')
functions_dir = profile
downloader = downloader.SimpleDownloader()
debug = addon.getSetting('debug')

if os.path.exists(favorites) == True:
    FAV = open(favorites).read()
else: FAV = []
if os.path.exists(favorites) == True:
    FAV = open(favorites).read()
else: FAV = []

DIRS = []
STRM_LOC = xbmc.translatePath(addon.getSetting('STRM_LOC'))

def requestItem(file, fletype='video'):
    utils.addon_log("requestItem") 
    json_query = ('{"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":1,"properties":["thumbnail","fanart","title","year","mpaa","imdbnumber","description","season","episode","playcount","genre","duration","runtime","showtitle","album","artist","plot","plotoutline","tagline","tvshowid"]}, "id": 1}')
コード例 #47
0
def get_video(url, name, plot, studio, episode, thumb, date):
	result = getUrl(url)
	video_id = re.compile('player\.loadRevision3Item\(\'video_id\',(.+?)\);').findall(result)[0].replace(' ','')
	api = getUrl('http://revision3.com/api/flash?video_id=' + video_id)
	videos_api = common.parseDOM(api, "media", ret = "type")
	videos_api[:] = (value for value in videos_api if value != 'thumbnail')
	durl = {}
	for type_api in videos_api:
		content_api = clean(common.parseDOM(api, "media", attrs = { "type": type_api })[0])
		durl[type_api] = content_api
	list = ['MP4','Quicktime','Xvid','WMV','Unknown File Type']
	for type in list:
		content = common.parseDOM(result, "div", attrs = { "id": "action-panels-download-" + type })
		videos = common.parseDOM(content, "a", attrs = { "class": "sizename" })
		links = common.parseDOM(content, "a", attrs = { "class": "sizename" }, ret="href")
		count = 0
		for add in videos:
			if type == 'Unknown File Type':
				code = type
			else:
				code = type + ':' + add
			durl[code] = links[count]
			count += 1
	dictList = [] 
	for key, value in durl.iteritems():
		dictList.append(key)
	quality = settings.getSetting('type')
	try:
		try:
			purl = durl[quality]
		except:
			if quality == 'MP4:HD':
				if 'Quicktime:HD' in durl:
					quality_api = 'Quicktime:HD'
				else:
					quality_api = 'hd'
			if quality == 'MP4:Large':
				if 'Quicktime:Large' in durl:
					quality_api = 'Quicktime:Large'
				else:
					quality_api = 'high'
			if quality == 'MP4:Phone':
				quality_api = 'low'
			purl = durl[quality_api]
		ret = None
	except:
		dialog = xbmcgui.Dialog()
		ret = dialog.select(settings.getLocalizedString( 30017 ), dictList)
		purl = durl[dictList[ret]]
	if ret != -1:
		if settings.getSetting('download') == 'true':
			while not settings.getSetting('downloadPath'):
				if settings.getSetting('download') == 'false':
					xbmc.executebuiltin("Container.Refresh")
					return
				dialog = xbmcgui.Dialog()
				ok = dialog.ok(plugin, settings.getLocalizedString( 30011 ))
				settings.openSettings()
			params = { "url": purl, "download_path": settings.getSetting('downloadPath'), "Title": name }
			downloader.download(clean_file(name) + '.' + purl.split('/')[-1].split('.')[-1], params)
		else:
			infoLabels = { "Title": name, "Studio": 'Revision3: ' + studio, "Plot": plot, "Episode": int(episode), "Aired": date  }
			playListItem(label = name, image = thumb, path = purl, infoLabels = infoLabels, PlayPath = False)