-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Showing
4 changed files
with
73 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,49 @@ | ||
"""Helpers for Kodi GUI.""" | ||
|
||
from xbmcgui import ListItem | ||
import inputstreamhelper | ||
|
||
|
||
def create_directory_items(data: list) -> list: | ||
"""Create a list of directory items from data.""" | ||
items = [] | ||
def create_list_item(item_data: dict, is_folder: bool = False) -> ListItem: | ||
"""Create a list item from data.""" | ||
list_item = ListItem(label=item_data.get("label"), path=item_data.get("path")) | ||
|
||
if "art" in item_data: | ||
item_art_data: dict = item_data.get("art", {}) | ||
list_item.setArt( | ||
{ | ||
"poster": item_art_data.get("poster"), | ||
"thumb": item_art_data.get("thumb"), | ||
} | ||
) | ||
|
||
if not is_folder: | ||
list_item.setProperties( | ||
{ | ||
"IsPlayable": "true", | ||
} | ||
) | ||
|
||
if "info" in item_data: | ||
item_info_data: dict = item_data.get("info", {}) | ||
video_info_tag = list_item.getVideoInfoTag() | ||
video_info_tag.setDuration(item_info_data.get("duration")) | ||
video_info_tag.setGenres(item_info_data.get("genres")) | ||
video_info_tag.setPlot(item_info_data.get("plot")) | ||
video_info_tag.setYear(item_info_data.get("year")) | ||
|
||
for d in data: | ||
is_folder = bool(d["is_folder"]) | ||
|
||
list_item = ListItem(label=d["label"], path=d["path"]) | ||
list_item.setIsFolder(is_folder) | ||
|
||
if "art" in d: | ||
list_item.setArt( | ||
{ | ||
"poster": d["art"].get("poster", None), | ||
"thumb": d["art"].get("thumb", None), | ||
} | ||
) | ||
|
||
if not is_folder: | ||
list_item.setProperties( | ||
{ | ||
"inputstream": "inputstream.adaptive", | ||
"IsPlayable": "true", | ||
} | ||
) | ||
|
||
if "info" in d: | ||
video_info_tag = list_item.getVideoInfoTag() | ||
video_info_tag.setDuration(d["info"].get("duration", None)) | ||
video_info_tag.setGenres(d["info"].get("genres", None)) | ||
video_info_tag.setPlot(d["info"].get("plot", None)) | ||
video_info_tag.setYear(d["info"].get("year", None)) | ||
video_info_tag.setPremiered(d["info"].get("premiered", None)) | ||
|
||
items.append((d["path"], list_item, is_folder)) | ||
|
||
return items | ||
|
||
|
||
def create_video_item(stream_info: dict) -> ListItem: | ||
"""Create a video item from stream data.""" | ||
|
||
is_helper = inputstreamhelper.Helper(stream_info['manifest_type'], | ||
drm = stream_info["license_type"]) | ||
|
||
if is_helper.check_inputstream(): | ||
list_item = ListItem(path=stream_info["path"]) | ||
return list_item | ||
|
||
list_item.setContentLookup(False) | ||
list_item.setMimeType(stream_info["mime_type"]) | ||
|
||
list_item.setProperty('inputstream', is_helper.inputstream_addon) | ||
def create_play_item(stream_info: dict, inputstream_addon: str) -> ListItem: | ||
"""Create a play item from stream data.""" | ||
play_item = ListItem(path=stream_info["path"]) | ||
play_item.setContentLookup(False) | ||
play_item.setMimeType(stream_info["mime_type"]) | ||
|
||
list_item.setProperty('inputstream.adaptive.manifest_type', stream_info['manifest_type']) | ||
list_item.setProperty('inputstream.adaptive.license_type', stream_info["license_type"]) | ||
list_item.setProperty("inputstream.adaptive.license_key", stream_info["license_key"]) | ||
play_item.setProperty("inputstream", inputstream_addon) | ||
# play_item.setProperty("inputstream.adaptive.play_timeshift_buffer", "true") | ||
# play_item.setProperty("inputstream.adaptive.manifest_config", '{"timeshift_bufferlimit":14400}') | ||
play_item.setProperty("inputstream.adaptive.license_type", stream_info["license_type"]) | ||
play_item.setProperty("inputstream.adaptive.license_key", stream_info["license_key"]) | ||
|
||
return list_item | ||
return play_item |