Skip to content

Commit

Permalink
Client Id y secret correctos para cada región
Browse files Browse the repository at this point in the history
  • Loading branch information
pablouser1 committed Feb 11, 2023
1 parent 42ca352 commit b8c0a15
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
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.6.0" provider-name="pablouser1">
<addon id="plugin.video.filmin" name="Filmin" version="1.6.1" 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.6.0 (10/02/2023)
Soporte inicial a Filmin Portugal y Filmin México
v1.6.1 (11/02/2023)
Client-Id y Client-Secret correctos
</news>
<assets>
<icon>resources/icon.png</icon>
Expand Down
35 changes: 31 additions & 4 deletions resources/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@
from xbmc import getLanguage, ISO_639_1
from .exceptions.ApiV3Exception import ApiV3Exception
from .exceptions.UApiException import UApiException
from .exceptions.DialogException import DialogException

class Api:
s = requests.Session()

# Both extracted from the Android app
CLIENT_ID = "zXZXrpum7ayGcWlo"
CLIENT_SECRET = "yICstBCQ8CKB8RF6KuDmr9R20xtfyYbm"
# Taken from es.filmin.app.BuildConfig
TOKENS = {
# Spain
'es': {
'CLIENT_ID': 'zXZXrpum7ayGcWlo',
'CLIENT_SECRET': 'yICstBCQ8CKB8RF6KuDmr9R20xtfyYbm'
},
# Portugal
'pt': {
'CLIENT_ID': 'zhiv2IKILLYNZ3pq',
'CLIENT_SECRET': 'kzPKMK2aXJzFoHNWOCR6gcd60WTK1BL3'
},
# México
'mx': {
'CLIENT_ID': 'sse7QwjpcNoZgGZO',
'CLIENT_SECRET': '2yqTm7thQLc2NQUQSbKehn7xrg1Pi59q'
}
}

CLIENT_ID = ""
CLIENT_SECRET = ""

DEVICE_MODEL = 'Kodi'
DEVICE_OS_VERSION = '12'
Expand All @@ -17,7 +36,6 @@ class Api:
domain = 'es'

def __init__(self, domain: str):
self.s.headers["X-Client-Id"] = self.CLIENT_ID
self.s.headers["clientlanguage"] = getLanguage(ISO_639_1, True)

self.s.headers["clientversion"] = self.CLIENT_VERSION
Expand All @@ -30,6 +48,11 @@ def __init__(self, domain: str):
self.s.headers['X-Device-OS-Version'] = self.DEVICE_OS_VERSION

self.domain = domain
tokens = self.TOKENS[domain]
self.CLIENT_ID = tokens['CLIENT_ID']
self.CLIENT_SECRET = tokens['CLIENT_SECRET']

self.s.headers["X-Client-Id"] = self.CLIENT_ID

def getApiBaseUrl(self, useUapi: bool = False)-> str:
# Extracted from Android app: es.filmin.app.injector.modules.RestApiUrlProviderEx
Expand All @@ -40,6 +63,10 @@ def getApiBaseUrl(self, useUapi: bool = False)-> str:
def makeRequest(self, endpoint: str, method = 'GET', body: dict = {}, query: dict = {}, useUapi: bool = False):
base_url = self.getApiBaseUrl(useUapi)
res = self.s.request(method, base_url + endpoint, json=body, params=query)
# Avoid non JSON response
if res.headers.get('Content-Type') != 'application/json':
raise DialogException('Non JSON response')

res_json = res.json()
if res.ok:
return res_json
Expand Down
9 changes: 9 additions & 0 deletions resources/lib/exceptions/DialogException.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from xbmcgui import Dialog

class DialogException(Exception):
"""
Generic exception using Dialogs
"""
def __init__(self, message: str):
super().__init__()
Dialog().ok('Error', message)

0 comments on commit b8c0a15

Please sign in to comment.