From aa9e52e5aa55e8e2d3583119bc14ce1ada3acd96 Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Wed, 4 Jan 2023 16:15:52 +0100 Subject: [PATCH] =?UTF-8?q?Rollback=20de=201.5.1=20con=20mejoras=20en=20re?= =?UTF-8?q?producci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + addon.xml | 6 ++--- resources/lib/api.py | 42 +++++++++++++-------------------- resources/lib/helpers/Misc.py | 3 +++ resources/lib/player/Handler.py | 15 ++++-------- resources/lib/player/Player.py | 3 ++- 6 files changed, 31 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index fd4729f..315d154 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ /.vscode +/tests.py diff --git a/addon.xml b/addon.xml index 96479eb..a6c44aa 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -19,8 +19,8 @@ https://github.com/pablouser1/plugin.video.filmin http://github.com/pablouser1/plugin.video.filmin - v1.5.1 (03/01/2023) - Arreglados varios errores que hacían imposible reproducir contenido + v1.5.2 (04/01/2023) + Rollback de 1.5.1 y agregadas mejoras en reproducción resources/icon.png diff --git a/resources/lib/api.py b/resources/lib/api.py index 440148c..cf697dc 100644 --- a/resources/lib/api.py +++ b/resources/lib/api.py @@ -9,12 +9,12 @@ class Api: s = requests.Session() # Both extracted from the Android app - CLIENT_ID = "5dV4xPOpaTPjPpNm" + CLIENT_ID = "zXZXrpum7ayGcWlo" CLIENT_SECRET = "yICstBCQ8CKB8RF6KuDmr9R20xtfyYbm" DEVICE_MODEL = 'Kodi' DEVICE_OS_VERSION = '12' - CLIENT_VERSION = "4.2.440" + CLIENT_VERSION = "4.3.4" def __init__(self): self.s.headers["X-Client-Id"] = self.CLIENT_ID @@ -155,31 +155,23 @@ def useTicket(self, item_id: int): 'id': item_id }) - def getStreams(self, item_id: int): - versions = [] + def getStreams(self, item_id: int) -> dict: res = self.makeRequest(endpoint=f'/version/{item_id}') + streams = {} + # -- Single feed -- # + if not 'feeds' in res: + # We have to convert it to the multi-feed response + streams = { + 'feeds': [res], + 'media_viewing_id': res['media_viewing_id'], + 'xml': res['xml'] + } + # -- More than one feed -- # + else: + # Leave it as it is + streams = res - # -- FILMIN V2 (DRM) -- # - # Multiple feeds - if 'feeds' in res: - for feed in res['feeds']: - feed["drm"] = True - versions.append(feed) - # Only one feed - elif type(res) is dict and 'license_url' in res: - res["drm"] = True - versions.append(res) - - # -- FILMIN V1 (DRM-FREE) -- # - elif 'FLVURL' in res: - versions.append({ - "type": "FLVURL", - "src": res["FLVURL"], - "media_viewing_id": res["media_viewing_id"], - "drm": False - }) - - return versions + return streams # -- HELPERS -- # def setToken(self, token: str): diff --git a/resources/lib/helpers/Misc.py b/resources/lib/helpers/Misc.py index e4113ae..026188b 100644 --- a/resources/lib/helpers/Misc.py +++ b/resources/lib/helpers/Misc.py @@ -1,2 +1,5 @@ def enum(**enums): return type('Enum', (), enums) + +def isDrm(stream_type: str)-> bool: + return stream_type in ['dash+http+widevine', 'dash+https+widevine'] diff --git a/resources/lib/player/Handler.py b/resources/lib/player/Handler.py index fef3235..0bb8851 100644 --- a/resources/lib/player/Handler.py +++ b/resources/lib/player/Handler.py @@ -3,6 +3,7 @@ from xbmcplugin import setResolvedUrl from ..common import api, config, _HANDLE from ..helpers.ListItemExtra import ListItemExtra +from ..helpers.Misc import isDrm from .Player import Player from ..exceptions.DRMException import DRMException from ..exceptions.StreamException import StreamException @@ -42,13 +43,6 @@ def versionPicker(self)-> dict: version = versions_filtered[index] return version - def streamPicker(self, version_id: int)-> dict: - # Choose first stream available - streams = api.getStreams(version_id) - if len(streams) == 0: - raise StreamException() - return streams[0] - def start(self): if not self.canWatch and config.canBuy(): self.buyMedia() @@ -61,11 +55,12 @@ def start(self): for subtitle in subtitles_api: subtitles.append(subtitle['subtitleFiles']['data'][0]['path']) - stream = self.streamPicker(version['id']) + streams = api.getStreams(version['id']) + stream = streams['feeds'][0] play_item = ListItemExtra.videoApiv3(stream['src'], self.item) play_item.setSubtitles(subtitles) # Add DRM config - if stream["drm"]: + if isDrm(stream['type']): import inputstreamhelper # pylint: disable=import-error is_helper = inputstreamhelper.Helper(self.PROTOCOL, drm=self.DRM) if is_helper.check_inputstream(): @@ -82,7 +77,7 @@ def start(self): config.getProfileId(), self.item['id'], version['id'], - stream['media_viewing_id'], + streams['media_viewing_id'], config.getToken()['access']) player.play(listitem=play_item) setResolvedUrl(_HANDLE, True, play_item) diff --git a/resources/lib/player/Player.py b/resources/lib/player/Player.py index 92c192f..5173bb0 100644 --- a/resources/lib/player/Player.py +++ b/resources/lib/player/Player.py @@ -47,4 +47,5 @@ def onPlayBackPaused(self): self.sync() def onPlayBackStopped(self): - self.timer.cancel() + if self.can_sync: + self.timer.cancel()