Skip to content

Commit

Permalink
Merge pull request t0mm0#7 from anarchintosh/master
Browse files Browse the repository at this point in the history
updated countdown script
  • Loading branch information
t0mm0 committed Sep 14, 2011
2 parents dbacede + e2ced0c commit ef31376
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
*.pyo
*.cookies
*.DS_Store
temp/*
script.module.urlresolver/resources/settings.xml
doc/build
Expand Down
32 changes: 19 additions & 13 deletions script.module.urlresolver/lib/urlresolver/countdown.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
'''
Countdown XBMC 0.2
Countdown XBMC 0.3
Copyleft Anarchintosh
Set a countdown dialog for XBMC.
Set a countdown dialog with a progress bar for XBMC.
Necessary for some filehosters eg. megaupload
'''

import xbmc, xbmcgui

def countdown(time_to_wait,title='',text=''):
return do_xbmc_wait(time_to_wait,title,text)

def do_xbmc_wait(time_to_wait,title,text):

print 'waiting '+str(time_to_wait)+' secs'
def countdown( time_to_wait, title='', text='' ):

time_to_wait = int(time_to_wait)

pDialog = xbmcgui.DialogProgress()
ret = pDialog.create(title)

print 'waiting '+str(time_to_wait)+' secs'

secs=0
percent=0
increment = 100 / time_to_wait

cancelled = False
while secs < time_to_wait:
secs = secs + 1
percent = increment*secs
while secs <= time_to_wait:

percent = increment * secs

secs_left = str((time_to_wait - secs))

if secs != 0: xbmc.sleep(1000)

if secs_left == '0': percent = 100

remaining_display = ' Wait '+secs_left+' seconds for the video stream to activate...'
pDialog.update(percent,' '+text,remaining_display)
xbmc.sleep(1000)

if (pDialog.iscanceled()):
cancelled = True
break

secs += 1

if cancelled == True:
print 'wait cancelled'
return False
else:
print 'done waiting'
return True

0 comments on commit ef31376

Please sign in to comment.