Skip to content

Commit

Permalink
Rollback de 1.5.1 con mejoras en reproducción
Browse files Browse the repository at this point in the history
  • Loading branch information
pablouser1 committed Jan 4, 2023
1 parent b136945 commit aa9e52e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__pycache__
/.vscode
/tests.py
6 changes: 3 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.filmin" name="Filmin" version="1.5.1" provider-name="pablouser1">
<addon id="plugin.video.filmin" name="Filmin" version="1.5.2" provider-name="pablouser1">
<requires>
<import addon="xbmc.python" version="3.0.0" />
<import addon="script.module.requests" version="2.22.0+matrix.1" />
Expand All @@ -19,8 +19,8 @@
<website>https://github.com/pablouser1/plugin.video.filmin</website>
<source>http://github.com/pablouser1/plugin.video.filmin</source>
<news>
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
</news>
<assets>
<icon>resources/icon.png</icon>
Expand Down
42 changes: 17 additions & 25 deletions resources/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions resources/lib/helpers/Misc.py
Original file line number Diff line number Diff line change
@@ -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']
15 changes: 5 additions & 10 deletions resources/lib/player/Handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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():
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/player/Player.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ def onPlayBackPaused(self):
self.sync()

def onPlayBackStopped(self):
self.timer.cancel()
if self.can_sync:
self.timer.cancel()

0 comments on commit aa9e52e

Please sign in to comment.