-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ff8a53
commit ce92de9
Showing
34 changed files
with
351 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import sys | ||
from sys import argv | ||
from urllib.parse import parse_qsl | ||
from .config import Config | ||
from .api import Api | ||
|
||
_URL = sys.argv[0] | ||
_HANDLE = int(sys.argv[1]) | ||
params = dict(parse_qsl(sys.argv[2][1:])) | ||
_URL = argv[0] | ||
_HANDLE = int(argv[1]) | ||
params = dict(parse_qsl(argv[2][1:])) | ||
config = Config() | ||
api = Api() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
def __enum(**enums): | ||
return type('Enum', (), enums) | ||
|
||
ROUTES = __enum( | ||
HOME='home', | ||
CATALOG='catalog', | ||
SEARCH='search', | ||
PURCHASED='purchased', | ||
WATCHING='watching', | ||
HIGHLIGHTEDS='highlighteds', | ||
PLAYLISTS='playlists', | ||
PLAYLIST='playlist', | ||
COLLECTIONS='collections', | ||
COLLECTION='collection', | ||
SEASONS='seasons', | ||
EPISODES='episodes', | ||
PLAYER='player' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from .common import params | ||
|
||
class Dispatcher: | ||
functions = {} | ||
args = {} | ||
kwargs = {} | ||
def register(self, route: str, args = [], kwargs = []): | ||
def add(f): | ||
if route in self.functions: | ||
raise Exception(f'{route} route already exists!') | ||
|
||
self.functions[route] = f | ||
self.args[route] = args | ||
self.kwargs[route] = kwargs | ||
return f | ||
|
||
return add | ||
|
||
def run(self, route: str): | ||
if route not in self.functions: | ||
raise Exception('Route not valid') | ||
|
||
args = [] | ||
kwargs = [] | ||
# Add args | ||
if self.args[route]: | ||
for arg in self.args[route]: | ||
if arg not in params: | ||
raise Exception('Param not found in URL!') | ||
|
||
args.append(params[arg]) | ||
|
||
self.functions[route](*args) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
videos_type = [ | ||
videos_type = ( | ||
"short", "film", "episode" | ||
] | ||
) | ||
|
||
folders_type = [ | ||
folders_type = ( | ||
"serie", "season" | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import requests | ||
|
||
class Mediamark: | ||
BASE_URL = "https://bm.filmin.es/mediamarks" | ||
AUTH_TOKEN = "Njk1MzM5MjAtNDVmNi0xMWUzLThmOTYtMDgwMDIwMGM5YTY2" # I -- THINK -- this is hardcoded, I hope so. | ||
CLIENT_ID = "zXZXrpum7ayGcWlo" | ||
s = requests.Session() | ||
TOKEN = '' | ||
USER_ID = 0 | ||
MEDIA_ID = 0 | ||
VERSION_ID = 0 | ||
MEDIA_VIEWING_ID = 0 | ||
SESSION_ID = 0 | ||
|
||
def __init__(self, user_id: int, media_id: int, version_id: int, media_viewing_id: int, session_id: str): | ||
self.USER_ID = user_id | ||
self.MEDIA_ID = media_id | ||
self.VERSION_ID = version_id | ||
self.MEDIA_VIEWING_ID = media_viewing_id | ||
self.SESSION_ID = session_id | ||
self.s.headers["X-CLIENT-ID"] = self.CLIENT_ID | ||
|
||
def setToken(self): | ||
res = self.s.post(self.BASE_URL + '/token', data={ | ||
'media_id': self.MEDIA_ID, | ||
'user_id': self.USER_ID, | ||
'platform': 'android' | ||
}) | ||
|
||
res_json = res.json() | ||
self.TOKEN = res_json['data']['token'] | ||
|
||
def getInitialPos(self)-> int: | ||
res = self.s.get(self.BASE_URL, params={ | ||
'token': self.TOKEN | ||
}) | ||
|
||
res_json = res.json() | ||
return int(res_json['data']['position']) | ||
|
||
def sync(self, time: int): | ||
self.s.post(self.BASE_URL, data={ | ||
'token': self.TOKEN, | ||
'position': time, | ||
'version_id': self.VERSION_ID, | ||
'duration': 0, | ||
'media_id': self.MEDIA_ID, | ||
'media_viewing_id': self.MEDIA_VIEWING_ID, | ||
'session_id': self.SESSION_ID, | ||
'session_connections': 2, | ||
'subtitle_id': 0 | ||
}) | ||
|
||
def sendPos(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import xbmc | ||
import xbmcgui | ||
from .Mediamark import Mediamark | ||
|
||
class Player(xbmc.Player): | ||
""" | ||
TODO, MAKE CUSTOM PLAYER WORK | ||
Custom player for Filmin | ||
KODI TIMES ARE IN SECONDS | ||
FILMIN TIMES ARE IN MILISECONDS | ||
""" | ||
can_sync = False | ||
ended = False | ||
mediamark: Mediamark | ||
|
||
def __init__(self, can_sync: bool, user_id: int, media_id: int, version_id: int, media_viewing_id: int, session_id: str): | ||
xbmc.Player.__init__(self) | ||
xbmc.log('STARTING CUSTOM PLAYER', xbmc.LOGINFO) | ||
self.can_sync = can_sync | ||
if self.can_sync: | ||
xbmc.log('Enabling sync to FILMIN', xbmc.LOGINFO) | ||
self.mediamark = Mediamark(user_id, media_id, version_id, media_viewing_id, session_id) | ||
|
||
def onAVStarted(self): | ||
if self.can_sync: | ||
self.mediamark.setToken() | ||
filmin_position = self.mediamark.getInitialPos() / 1000 # Last position set by Filmin converted to seconds | ||
kodi_position = self.getTime() # Kodi last position, already in seconds | ||
# Move video to Filmin position | ||
seek_to = filmin_position - kodi_position | ||
xbmc.log(f'Moving video to {seek_to} seconds relative', xbmc.LOGINFO) | ||
self.seekTime(seek_to) # seekTime is relative to the current Kodi position | ||
|
||
def onPlayBackSeek(self, time: int, seekOffset: int): | ||
if self.can_sync: | ||
xbmc.log(f'Syncing to Filmin at {time} seconds', xbmc.LOGINFO) | ||
time_ms = time * 1000 | ||
self.mediamark.sync(time_ms) | ||
|
||
def onPlayBackPaused(self): | ||
if self.can_sync: | ||
time = self.getTime() | ||
time_ms = time * 1000 | ||
xbmc.log(f'Syncing to Filmin at {time} seconds', xbmc.LOGINFO) | ||
self.mediamark.sync(time_ms) | ||
|
||
def onPlayBackStopped(self): | ||
if self.can_sync: | ||
time = self.getTime() | ||
time_ms = time * 1000 | ||
xbmc.log(f'Syncing to Filmin at {time} seconds', xbmc.LOGINFO) | ||
self.mediamark.sync(time_ms) | ||
|
||
def onPlayBackEnded(self): | ||
self.ended = True |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.