import enigma2-plugin-extensions-mediaportal 2020082501 master v2020082501
authorChristian Weiske <cweiske@cweiske.de>
Tue, 25 Aug 2020 23:15:17 +0000 (01:15 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 25 Aug 2020 23:15:17 +0000 (01:15 +0200)
usr/lib/enigma2/python/Plugins/Extensions/MediaPortal/additions/porn/porntv.py
usr/lib/enigma2/python/Plugins/Extensions/MediaPortal/plugin.py

index aaca31c..de8c3cc 100644 (file)
@@ -141,9 +141,13 @@ class porntvGenreScreen(MPScreen):
                                        parse = re.search('class="cat-list(.*?)class="cat-list', data, re.S)
                Cats = re.findall('(?:class="item(?: video-category|)"|<div style=).*?href="(.*?)".*?src="(.*?)".*?title="(.*?)"', parse.group(1), re.S)
                if Cats:
+                       print('#######################1')
                        for (Url, Image, Title) in Cats:
+                               print(Url, Image, Title)
                                if not "galleries" in Url:
                                        Title = Title.replace(' Videos', '').replace(' Movies', '').replace(' Tube', '')
+                                       if Title == '':
+                                               Title = Url.replace('-popular.html', '').replace('-recent.html', '').split('/')[-1]
                                        if Url.endswith('.html'):
                                                Url = Url.replace('-popular.html', '-recent.html').split('.html')[0] + "-$$PAGE$$.html"
                                                if Url.startswith('/'):
@@ -340,8 +344,33 @@ class porntvFilmScreen(MPScreen):
                        twAgentGetPage(url).addCallback(self.getVideoPage).addErrback(self.dataError)
 
        def getVideoPage(self, data):
-               url = re.findall('file:\s"(.*?)",.*?label:\s"\d+p', data, re.S)
-               if url:
+               url = re.findall('file:\s"(.*?)",.*?label:\s"(?:\d+p|0)', data, re.S)
+               if url and not ".m3u8" in url[0]:
                        self.keyLocked = False
                        title = self['liste'].getCurrent()[0][0]
-                       self.session.open(SimplePlayer, [(title, url[0])], showPlaylist=False, ltype='porntv')
\ No newline at end of file
+                       self.session.open(SimplePlayer, [(title, url[0])], showPlaylist=False, ltype='porntv')
+               else:
+                       baseurl = url[0].split('master.m3u8')[0]
+                       twAgentGetPage(url[0], timeout=10).addCallback(self.loadplaylist, baseurl).addErrback(self.dataError)
+
+       def loadplaylist(self, data, baseurl):
+               self.bandwith_list = []
+               match_sec_m3u8=re.findall('BANDWIDTH=(\d+).*?\n(.*?.m3u8.*?)(?:\n|$)', data, re.S)
+               max = 0
+               for x in match_sec_m3u8:
+                       if int(x[0]) > max:
+                               max = int(x[0])
+               videoPrio = int(config_mp.mediaportal.videoquali_others.value)
+               if videoPrio == 2:
+                       bw = max
+               elif videoPrio == 1:
+                       bw = max / 2
+               else:
+                       bw = max / 3
+               for each in match_sec_m3u8:
+                       bandwith, url = each
+                       self.bandwith_list.append((int(bandwith), url))
+               _x, best = min((abs(int(x[0]) - bw), x) for x in self.bandwith_list)
+               url = baseurl + best[1]
+               title = self['liste'].getCurrent()[0][0]
+               self.session.open(SimplePlayer, [(title, url)], showPlaylist=False, ltype='porntv')
\ No newline at end of file
index ea4fa2e..7a8b19d 100644 (file)
@@ -113,7 +113,7 @@ config_mp.mediaportal = ConfigSubsection()
 config_mp.mediaportal.fake_entry = NoSave(ConfigNothing())
 
 # Allgemein
-config_mp.mediaportal.version = NoSave(ConfigText(default="2020082401"))
+config_mp.mediaportal.version = NoSave(ConfigText(default="2020082501"))
 config_mp.mediaportal.autoupdate = ConfigYesNo(default = True)
 
 config_mp.mediaportal.skinfail = ConfigYesNo(default = False)
@@ -168,7 +168,7 @@ if mp_globals.model in ["one", "two", "dm900", "dm920"]:
 else:
        config_mp.mediaportal.plugin_viewmode = ConfigYesNo(default = False)
 config_mp.mediaportal.storagepath = ConfigText(default="/tmp/mediaportal/tmp/", fixed_size=False)
-config_mp.mediaportal.iconcachepath = ConfigText(default="/media/hdd/mediaportal/", fixed_size=False)
+config_mp.mediaportal.iconcachepath = ConfigText(default="/data/mediaportal/", fixed_size=False)
 config_mp.mediaportal.autoplayThreshold = ConfigInteger(default = 50, limits = (1, 100))
 config_mp.mediaportal.filter = ConfigSelectionExt(default = "ALL", choices = ["ALL", "Mediathek", "User-additions", "Fun", "NewsDoku", "Sport", "Music", "Porn"])
 config_mp.mediaportal.youtubeenablevp9 = ConfigYesNo(default = False)
@@ -317,31 +317,31 @@ class CheckPathes(object):
                        self.session.openWithCallback(self._callback, MessageBoxExt, msg, MessageBoxExt.TYPE_ERROR)
 
                if mp_globals.pluginPath in config_mp.mediaportal.iconcachepath.value:
-                       config_mp.mediaportal.iconcachepath.value = "/media/hdd/mediaportal/"
+                       config_mp.mediaportal.iconcachepath.value = "/data/mediaportal/"
                        config_mp.mediaportal.iconcachepath.save()
                        configfile_mp.save()
                elif config_mp.mediaportal.iconcachepath.value.startswith('/tmp/'):
-                       config_mp.mediaportal.iconcachepath.value = "/media/hdd/mediaportal/"
+                       config_mp.mediaportal.iconcachepath.value = "/data/mediaportal/"
                        config_mp.mediaportal.iconcachepath.save()
                        configfile_mp.save()
                elif config_mp.mediaportal.iconcachepath.value.startswith('/etc/'):
-                       config_mp.mediaportal.iconcachepath.value = "/media/hdd/mediaportal/"
+                       config_mp.mediaportal.iconcachepath.value = "/data/mediaportal/"
                        config_mp.mediaportal.iconcachepath.save()
                        configfile_mp.save()
                elif config_mp.mediaportal.iconcachepath.value.startswith('/usr/lib/enigma2/'):
-                       config_mp.mediaportal.iconcachepath.value = "/media/hdd/mediaportal/"
+                       config_mp.mediaportal.iconcachepath.value = "/data/mediaportal/"
                        config_mp.mediaportal.iconcachepath.save()
                        configfile_mp.save()
                elif config_mp.mediaportal.iconcachepath.value.startswith('/var/volatile/'):
-                       config_mp.mediaportal.iconcachepath.value = "/media/hdd/mediaportal/"
+                       config_mp.mediaportal.iconcachepath.value = "/data/mediaportal/"
                        config_mp.mediaportal.iconcachepath.save()
                        configfile_mp.save()
                elif config_mp.mediaportal.iconcachepath.value.startswith('/var/share/'):
-                       config_mp.mediaportal.iconcachepath.value = "/media/hdd/mediaportal/"
+                       config_mp.mediaportal.iconcachepath.value = "/data/mediaportal/"
                        config_mp.mediaportal.iconcachepath.save()
                        configfile_mp.save()
                elif config_mp.mediaportal.iconcachepath.value.startswith('/usr/share/'):
-                       config_mp.mediaportal.iconcachepath.value = "/media/hdd/mediaportal/"
+                       config_mp.mediaportal.iconcachepath.value = "/data/mediaportal/"
                        config_mp.mediaportal.iconcachepath.save()
                        configfile_mp.save()
 
@@ -2285,6 +2285,10 @@ class MPSummary(Screen):
                                disp_id = ' id="2"'
                                disp_size = str(displaysize.width()) + "," + str(displaysize.height())
                                disp_pos = "0,0"
+                       elif mp_globals.model in ["two"]:
+                               disp_id = ' id="100"'
+                               disp_size = str(displaysize.width()) + "," + str(displaysize.height())
+                               disp_pos = "0,0"
                        else:
                                disp_id = ' id="1"'
                                disp_size = str(displaysize.width()) + "," + str(displaysize.height())
@@ -2764,7 +2768,7 @@ def startMP(session):
 
 def autostart(reason, session=None, **kwargs):
        "called with reason=1 to during shutdown, with reason=0 at startup?"
-       global _session, watcher, preload_list
+       global _session, watcher, preload_list, _cachingDeferred, _cachingPicload
        if reason == 0:
                if session is not None:
                        _session = session
@@ -2774,6 +2778,9 @@ def autostart(reason, session=None, **kwargs):
                if preload_list == None:
                        preload_list = []
                        if config_mp.mediaportal.viewmode.value == "grid":
+                               _cachingDeferred = defer.DeferredSemaphore(tokens=1)
+                               _cachingPicload = ePicLoad()
+                               _cachingPicload.setPara((1, 1, 1, 1, False, 1, "#FF000000"))
                                icon_url = getIconUrl()
                                path = config_mp.mediaportal.iconcachepath.value + "icons"
                                icons_hashes = grabpage(icon_url+"icons/hashes")
@@ -2788,7 +2795,7 @@ def autostart(reason, session=None, **kwargs):
                                                                i += 1
 
 def cacheIcon(threadName, fn, index):
-       global preload_list
+       global _cachingDeferred
        file = '/tmp/.gridIcon%s' % str(index)
        im = Image.open("%s/%s" % (config_mp.mediaportal.iconcachepath.value + "icons", fn)).convert('RGBA')
        im.load()
@@ -2799,16 +2806,23 @@ def cacheIcon(threadName, fn, index):
                bands = [b.resize((150, 80), Image.ANTIALIAS) for b in bands]
        im = Image.merge('RGBA', bands)
        im.save(file, "PNG")
-       picload = ePicLoad()
-       picload.setPara((1, 1, 1, 1, False, 1, "#FF000000"))
-       picload.startDecode(file, False)
-       pngthumb = picload.getData()
-       del picload
+       import sys
+       sys.setrecursionlimit(2000)
+       _cachingDeferred.run(loadIcon, fn, file).addErrback(failIcon)
+
+def loadIcon(fn, file):
+       global preload_list, _cachingPicload
+       _cachingPicload.startDecode(file, False)
+       pngthumb = _cachingPicload.getData()
        preload_list.append((fn, pngthumb))
        if fileExists(file):
                BgFileEraser = eBackgroundFileEraser.getInstance()
                BgFileEraser.erase(file)
 
+def failIcon(error):
+       from .resources.debuglog import printl
+       printl(error, '', "H")
+
 def cb_checkPathes():
        pass