Skip to content

Commit 8cfccdc

Browse files
authored
Merge pull request #120 from mediathekview/develop
Release 0.6.2
2 parents 06b3877 + 8937c97 commit 8cfccdc

6 files changed

Lines changed: 81 additions & 25 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.pyo
44
*.pyc
55
*.db
6+
__pycache__
67
/Filmliste-*
78
/.vscode
89
/venv

addon.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="plugin.video.mediathekview"
33
name="MediathekView"
4-
version="0.6.0"
4+
version="0.6.2"
55
provider-name="MediathekView.de, Leo Moll">
66
<requires>
77
<import addon="xbmc.python" version="2.25.0"/>
@@ -26,7 +26,13 @@
2626
<description lang="de_DE">Ermöglicht den Zugriff auf fast alle deutschen Mediatheken der öffentlich Rechtlichen basierend auf der Datenbank von MediathekView.de</description>
2727
<description lang="en_GB">Gives access to most video-platforms from German public service broadcasters using the database of MediathekView.de</description>
2828
<description lang="it_IT">Fornisce l'accesso a gran parte delle piattaforme video operate dalle emittenti pubbliche tedesche usando la banca dati di MediathekView.de</description>
29-
<news>v0.6.0 (2019-03-01):
29+
<news>v.0.6.2 (2019-03-10):
30+
- Bugfix: Entpacken von GZ-Archiven auf FireTV 4K und ähnliche Geräte funktioniert nun wieder
31+
- Bugfix: mvupdate funktioniert nun wieder
32+
- Compliance: Code Kompatibilität für zukünftige Kodi Versionen mit Python 3
33+
v.0.6.1 (2019-03-08):
34+
- Bugfix: Fixed module exception due to case error
35+
v0.6.0 (2019-03-01):
3036
- Feature: Cache der Anfragen für lokale Datenbanken
3137
- Feature: Natives ultraschnelles Update für SQLite
3238
- Bugfix: Live Streams konnten heruntergeladen werden

resources/lib/kodi/kodiaddon.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
"""
33
The Kodi addons module
44
5-
Copyright 2017-2018, Leo Moll and Dominik Schlösser
5+
Copyright 2017-2019, Leo Moll and Dominik Schlösser
66
Licensed under MIT License
77
"""
88
import os
99
import sys
10-
import urllib
11-
import urlparse
1210

1311
# pylint: disable=import-error
1412
import xbmc
1513
import xbmcgui
1614
import xbmcaddon
1715
import xbmcplugin
1816

17+
try:
18+
# Python 3.x
19+
from urllib.parse import urlencode
20+
from urllib.parse import parse_qs
21+
except ImportError:
22+
# Python 2.x
23+
from urllib import urlencode
24+
from urlparse import parse_qs
25+
1926
from resources.lib.kodi.kodilogger import KodiLogger
2027

2128

@@ -96,7 +103,7 @@ class KodiPlugin(KodiAddon):
96103

97104
def __init__(self):
98105
KodiAddon.__init__(self)
99-
self.args = urlparse.parse_qs(sys.argv[2][1:])
106+
self.args = parse_qs(sys.argv[2][1:])
100107
self.base_url = sys.argv[0]
101108
self.addon_handle = int(sys.argv[1])
102109

@@ -141,7 +148,7 @@ def build_url(self, params):
141148
Args:
142149
params(object): an object containing parameters
143150
"""
144-
return self.base_url + '?' + urllib.urlencode(params)
151+
return self.base_url + '?' + urlencode(params)
145152

146153
def run_plugin(self, params):
147154
"""

resources/lib/mvupdate.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class Settings(object):
2525
def __init__(self, args):
2626
self.datapath = args.path if args.dbtype == 'sqlite' else './'
2727
self.type = {'sqlite': 0, 'mysql': 1}.get(args.dbtype, 0)
28-
if self.type == 1:
28+
if self.type == 0:
29+
self.updnative = args.native
30+
elif self.type == 1:
2931
self.host = args.host
3032
self.port = int(args.port)
3133
self.user = args.user
@@ -38,7 +40,6 @@ def __init__(self, args):
3840
self.recentmode = 0
3941
self.groupshows = False
4042
self.updmode = 3
41-
self.updnative = args.native
4243
self.updinterval = args.intervall
4344

4445
@staticmethod

resources/lib/mvutils.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
import stat
1414
import string
1515

16-
import urllib
17-
import urllib2
16+
# pylint: disable=import-error
17+
try:
18+
# Python 3.x
19+
from urllib.parse import urlencode
20+
from urllib.request import urlopen
21+
except ImportError:
22+
from urllib import urlencode
23+
from urllib2 import urlopen
1824

1925
from contextlib import closing
2026
from resources.lib.exceptions import ExitRequested
@@ -108,12 +114,23 @@ def file_rename(srcname, dstname):
108114
return False
109115

110116

117+
def find_gzip():
118+
"""
119+
Return the full pathname to the gzip decompressor
120+
executable
121+
"""
122+
for gzbin in ['/bin/gzip', '/usr/bin/gzip', '/usr/local/bin/gzip', '/system/bin/gzip']:
123+
if file_exists(gzbin):
124+
return gzbin
125+
return None
126+
127+
111128
def find_xz():
112129
"""
113130
Return the full pathname to the xz decompressor
114131
executable
115132
"""
116-
for xzbin in ['/bin/xz', '/usr/bin/xz', '/usr/local/bin/xz']:
133+
for xzbin in ['/bin/xz', '/usr/bin/xz', '/usr/local/bin/xz', '/system/bin/xz']:
117134
if file_exists(xzbin):
118135
return xzbin
119136
return None
@@ -125,7 +142,7 @@ def make_search_string(val):
125142
containing only a well defined set of characters
126143
for a simplified search
127144
"""
128-
cset = string.letters + string.digits + ' _-#'
145+
cset = string.ascii_letters + string.digits + ' _-#'
129146
search = ''.join([c for c in val if c in cset])
130147
return search.upper().strip()
131148

@@ -156,7 +173,7 @@ def cleanup_filename(val):
156173
Args:
157174
val(str): input string
158175
"""
159-
cset = string.letters + string.digits + \
176+
cset = string.ascii_letters + string.digits + \
160177
u' _-#äöüÄÖÜßáàâéèêíìîóòôúùûÁÀÉÈÍÌÓÒÚÙçÇœ'
161178
search = ''.join([c for c in val if c in cset])
162179
return search.strip()
@@ -185,7 +202,7 @@ def url_retrieve(url, filename, reporthook, chunk_size=8192, aborthook=None):
185202
each block read thereafter. If specified the operation will be
186203
aborted if the hook function returns `True`
187204
"""
188-
with closing(urllib2.urlopen(url)) as src, closing(open(filename, 'wb')) as dst:
205+
with closing(urlopen(url)) as src, closing(open(filename, 'wb')) as dst:
189206
_chunked_url_copier(src, dst, reporthook, chunk_size, aborthook)
190207

191208

@@ -213,7 +230,7 @@ def url_retrieve_vfs(url, filename, reporthook, chunk_size=8192, aborthook=None)
213230
each block read thereafter. If specified the operation will be
214231
aborted if the hook function returns `True`
215232
"""
216-
with closing(urllib2.urlopen(url)) as src, closing(xbmcvfs.File(filename, 'wb')) as dst:
233+
with closing(urlopen(url)) as src, closing(xbmcvfs.File(filename, 'wb')) as dst:
217234
_chunked_url_copier(src, dst, reporthook, chunk_size, aborthook)
218235

219236

@@ -224,7 +241,7 @@ def build_url(query):
224241
Args:
225242
query(object): a query object
226243
"""
227-
return sys.argv[0] + '?' + urllib.urlencode(query)
244+
return sys.argv[0] + '?' + urlencode(query)
228245

229246

230247
def _chunked_url_copier(src, dst, reporthook, chunk_size, aborthook):

resources/lib/updater.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@
88
# -- Imports ------------------------------------------------
99
import os
1010
import time
11-
import urllib2
1211
import datetime
1312
import subprocess
1413

14+
# pylint: disable=import-error
15+
try:
16+
# Python 3.x
17+
from urllib.error import URLError
18+
except ImportError:
19+
# Python 2.x
20+
from urllib2 import URLError
21+
1522
from contextlib import closing
1623

1724
import ijson
@@ -338,7 +345,7 @@ def get_newest_list(self, full):
338345
reporthook=self.notifier.hook_download_progress,
339346
aborthook=self.monitor.abort_requested
340347
)
341-
except urllib2.URLError as err:
348+
except URLError as err:
342349
self.logger.error('Failure downloading {} - {}', url, err)
343350
self.notifier.close_download_progress()
344351
self.notifier.show_download_error(url, err)
@@ -369,7 +376,7 @@ def get_newest_list(self, full):
369376
retval = self._decompress_gz(compfile, destfile)
370377
self.logger.info('Return {}', retval)
371378
else:
372-
# should nebver reach
379+
# should never reach
373380
pass
374381

375382
self.notifier.close_download_progress()
@@ -587,20 +594,36 @@ def _decompress_bz2(self, sourcefile, destfile):
587594
return 0
588595

589596
def _decompress_gz(self, sourcefile, destfile):
590-
"""
591597
blocksize = 8192
598+
# pylint: disable=broad-except
592599

593600
try:
594601
with open(destfile, 'wb') as dstfile, gzip.open(sourcefile) as srcfile:
595602
for data in iter(lambda: srcfile.read(blocksize), b''):
596603
dstfile.write(data)
597-
# pylint: disable=broad-except
598604
except Exception as err:
599-
self.logger.error('gz decompression of "{}" to "{}" failed: {}'.format(
600-
sourcefile, destfile, err))
605+
self.logger.error(
606+
'gz decompression of "{}" to "{}" failed: {}', sourcefile, destfile, err)
607+
if mvutils.find_gzip() is not None:
608+
gzip_binary = mvutils.find_gzip()
609+
self.logger.info(
610+
'Trying to decompress gzip file "{}" using {}...', sourcefile, gzip_binary)
611+
try:
612+
mvutils.file_remove(destfile)
613+
retval = subprocess.call([gzip_binary, '-d', sourcefile])
614+
self.logger.info('Calling {} -d {} returned {}',
615+
gzip_binary, sourcefile, retval)
616+
return retval
617+
except Exception as err:
618+
self.logger.error(
619+
'gz commandline decompression of "{}" to "{}" failed: {}',
620+
sourcefile, destfile, err)
601621
return -1
602622
return 0
603-
"""
623+
624+
# pylint: disable=pointless-string-statement
625+
"""
626+
def _decompress_gz(self, sourcefile, destfile):
604627
blocksize = 8192
605628
# pylint: disable=broad-except,line-too-long
606629
@@ -631,3 +654,4 @@ def _decompress_gz(self, sourcefile, destfile):
631654
sourcefile, destfile, err))
632655
return -1
633656
return 0
657+
"""

0 commit comments

Comments
 (0)