|
14 | 14 | import shutil
|
15 | 15 | import sys
|
16 | 16 | import tempfile
|
17 |
| -import time |
18 | 17 | from unicodedata import normalize
|
19 | 18 | from urllib import FancyURLopener, unquote, quote_plus, urlencode, quote
|
20 | 19 | from urlparse import parse_qs
|
|
63 | 62 |
|
64 | 63 | PAGE_ENCODING = 'latin1'
|
65 | 64 |
|
| 65 | +kodi_major_version = None |
| 66 | + |
66 | 67 |
|
67 | 68 | # ============================
|
68 | 69 | # Regular expression patterns
|
@@ -330,7 +331,6 @@ def _handle_compressed_subs(workdir, compressed_file, ext):
|
330 | 331 | """
|
331 | 332 | Uncompress 'compressed_file' in 'workdir'.
|
332 | 333 | """
|
333 |
| - kodi_major_version = int(xbmc.getInfoLabel('System.BuildVersion').split('.')[0]) |
334 | 334 | if ext == 'rar' and kodi_major_version >= 18:
|
335 | 335 | src = 'archive' + '://' + quote_plus(compressed_file) + '/'
|
336 | 336 | (cdirs, cfiles) = xbmcvfs.listdir(src)
|
@@ -509,12 +509,22 @@ def _cleanup_tempdirs(profile_path):
|
509 | 509 | log(u"Results: %d of %d dirs removed" % (ok, total + 1), level=LOGDEBUG)
|
510 | 510 |
|
511 | 511 |
|
| 512 | +def sleep(secs): |
| 513 | + """Sleeps efficiently for secs seconds""" |
| 514 | + if kodi_major_version > 13: |
| 515 | + xbmc.Monitor().waitForAbort(secs) |
| 516 | + else: |
| 517 | + xbmc.sleep(1000 * secs) |
| 518 | + |
| 519 | + |
512 | 520 | def main():
|
513 | 521 | """Main entry point of the script when it is invoked by XBMC."""
|
| 522 | + global kodi_major_version |
514 | 523 | # Get parameters from XBMC and launch actions
|
515 | 524 | params = get_params(sys.argv)
|
516 | 525 | action = params.get('action', 'Unknown')
|
517 | 526 | xbmc.log(u"SUBDIVX - Version: %s -- Action: %s" % (__version__, action), level=LOGNOTICE)
|
| 527 | + kodi_major_version = int(xbmc.getInfoLabel('System.BuildVersion').split('.')[0]) |
518 | 528 |
|
519 | 529 | if action in ('search', 'manualsearch'):
|
520 | 530 | item = {
|
@@ -591,7 +601,7 @@ def main():
|
591 | 601 | # Send end of directory to XBMC
|
592 | 602 | xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
593 | 603 |
|
594 |
| - time.sleep(2) |
| 604 | + sleep(2) |
595 | 605 | if __addon__.getSetting('show_nick_in_place_of_lang') == 'true':
|
596 | 606 | _double_dot_fix_hack(params['filename'].encode('utf-8'))
|
597 | 607 | _cleanup_tempdir(workdir, verbose=True)
|
|
0 commit comments