-
-
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
67f7679
commit f52fd40
Showing
21 changed files
with
280 additions
and
102 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
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
2 changes: 1 addition & 1 deletion
2
resources/lib/exceptions/ApiException.py → resources/lib/exceptions/ApiV3Exception.py
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,9 @@ | ||
from xbmcgui import Dialog | ||
|
||
class UApiException(Exception): | ||
""" | ||
Throw exception when HTTP code is diferent from 2XX | ||
""" | ||
def __init__(self, error: dict): | ||
super().__init__() | ||
Dialog().ok('Filmin API Error', error['title']) |
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,31 @@ | ||
class Art: | ||
@staticmethod | ||
def apiv3(artworks: list)-> dict: | ||
""" | ||
Sorts art for Filmin Menus | ||
""" | ||
poster = None | ||
card = None | ||
thumb = None | ||
for art in artworks: | ||
if art['image_type'] == 'poster': | ||
poster = art['path'] | ||
elif art['image_type'] == 'card': | ||
card = art['path'] | ||
elif art['image_type'] == 'poster-mini': | ||
thumb = art['path'] | ||
|
||
return { | ||
"poster": poster, | ||
"card": card, | ||
"thumb": thumb | ||
} | ||
|
||
@staticmethod | ||
def uapi(item: dict)-> dict: | ||
return { | ||
"poster": item.get("image_poster"), | ||
"card": item.get("image_card"), | ||
"landscape": item.get("image_highlighted") | ||
# "thumb": | ||
} |
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,88 @@ | ||
from xbmcgui import ListItem | ||
from .Art import Art | ||
|
||
class ListItemExtra: | ||
@staticmethod | ||
def video(url: str, item: dict) -> ListItem: | ||
if item.get('_type'): | ||
list_item = ListItemExtra.videoUapi(url, item) | ||
else: | ||
list_item = ListItemExtra.videoApiv3(url, item) | ||
|
||
# Common | ||
list_item.setProperty('isPlayable', 'true') | ||
list_item.setIsFolder(False) | ||
return list_item | ||
|
||
@staticmethod | ||
def folder(url: str, item: dict) -> ListItem: | ||
if item.get('_type'): | ||
list_item = ListItemExtra.folderUapi(url, item) | ||
else: | ||
list_item = ListItemExtra.folderApiv3(url, item) | ||
|
||
return list_item | ||
|
||
@staticmethod | ||
def videoUapi(url: str, item: dict) -> ListItem: | ||
list_item = ListItem(item['title'], path=url) | ||
info = { | ||
"title": item["title"], | ||
"year": item["year"], | ||
"plot": item["excerpt"], | ||
"director": item['director_names'], | ||
"rating": item["avg_votes"], | ||
"duration": item["duration_in_minutes"] * 60 # Filmin returns duration in minutes, Kodi wants it in seconds | ||
} | ||
list_item.setInfo('video', info) | ||
# ART | ||
list_item.setArt(Art.uapi(item)) | ||
return list_item | ||
|
||
@staticmethod | ||
def videoApiv3(url: str, item: dict) -> ListItem: | ||
list_item = ListItem(item['title'], path=url) | ||
info = { | ||
"title": item["title"], | ||
"originaltitle": item["original_title"], | ||
"year": item["year"], | ||
"plot": item["excerpt"], | ||
"director": item["first_director"], | ||
"rating": float(item["avg_votes_press"]) if item.get("avg_votes_press") else None, | ||
"userrating": item["avg_votes_users"] if item.get("avg_votes_users") else None, | ||
"duration": item["duration"] * 60 # Filmin returns duration in minutes, Kodi wants it in seconds | ||
} | ||
list_item.setInfo('video', info) | ||
# ART | ||
art = Art.apiv3(item["imageResources"]["data"]) | ||
list_item.setArt(art) | ||
return list_item | ||
|
||
@staticmethod | ||
def folderUapi(url: str, item: dict) -> ListItem: | ||
list_item = ListItem(item['title'], path=url) | ||
info = { | ||
"title": item["title"], | ||
"year": item["year"], | ||
"plot": item["excerpt"], | ||
"director": item['director_names'], | ||
"rating": item["avg_votes"], | ||
"duration": item["duration_in_minutes"] * 60 # Filmin returns duration in minutes, Kodi wants it in seconds | ||
} | ||
# ART | ||
list_item.setArt(Art.uapi(item)) | ||
return list_item | ||
|
||
@staticmethod | ||
def folderApiv3(url: str, item: dict) -> ListItem: | ||
list_item = ListItem(item['title'], path=url) | ||
info = { | ||
"title": item["title"], | ||
"plot": item.get('excerpt') | ||
} | ||
list_item.setInfo('video', info) | ||
if 'imageResources' in item: | ||
art = Art.apiv3(item["imageResources"]["data"]) | ||
list_item.setArt(art) | ||
|
||
return list_item |
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,2 @@ | ||
def enum(**enums): | ||
return type('Enum', (), enums) |
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,3 @@ | ||
videos_type = ( | ||
"short", "film", "episode" | ||
) | ||
|
||
folders_type = ( | ||
"serie", "season" | ||
) | ||
class Types: | ||
videos = ("short", "film", "episode") | ||
folders = ("serie", "season") |
Oops, something went wrong.