forked from moromete/plugin.video.streams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glob.py
32 lines (27 loc) · 917 Bytes
/
glob.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import xbmc, xbmcgui, xbmcaddon
import urllib, urllib2
addon = xbmcaddon.Addon('plugin.video.streams')
ADDON_VERSION = addon.getAddonInfo('version')
ADDON_PATH= addon.getAddonInfo('path')
DEBUG = addon.getSetting('debug')
def addon_log(string):
if DEBUG == 'true':
xbmc.log("[plugin.video.streams-%s]: %s" %(ADDON_VERSION, string))
def Downloader(url,dest,description,heading):
dp = xbmcgui.DialogProgress()
dp.create(heading,description,url)
dp.update(0)
urllib.urlretrieve(url,dest,lambda nb, bs, fs, url=url: _pbhook(nb,bs,fs,dp))
def _pbhook(numblocks, blocksize, filesize,dp=None):
try:
percent = int((int(numblocks)*int(blocksize)*100)/int(filesize))
dp.update(percent)
except:
percent = 100
dp.update(percent)
if dp.iscanceled():
#raise KeyboardInterrupt
dp.close()
def message(title, message):
dialog = xbmcgui.Dialog()
dialog.ok(title, message)