Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nexus remove deprecated function calls #54

Open
wants to merge 8 commits into
base: nexus-staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ msgctxt "#30039"
msgid "In an anime seasons view, only display dubs in either Japanese, your CR language or any of your configured subtitle languages."
msgstr "Zeige in der Season-Übersicht eines Anime nur Dubs in Japanisch, deiner CR Sprache oder in einer der von Dir konfigurierten Untertitel-Sprachen"

msgctxt "#30036"
msgid "Show dub language in Season View"
msgstr "Zeige die Audio-Sprache in der Season-Übersicht"

msgctxt "#30037"
msgid "In an anime seasons view, display a dub tag in front of the season name."
msgstr "Zeige in der Season-Übersicht eines Anime die Audio-Sprache vor dem Titel der Staffel."


# Crunchyroll Menue

Expand Down
8 changes: 8 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ msgctxt "#30039"
msgid "In an anime seasons view, only display dubs in either Japanese, your CR language or any of your configured subtitle languages."
msgstr "In an anime seasons view, only display dubs in either Japanese, your CR language or any of your configured subtitle languages."

msgctxt "#30036"
msgid "Show dub language in Season View"
msgstr "Show dub language in Season View"

msgctxt "#30037"
msgid "In an anime seasons view, display a dub tag in front of the season name."
msgstr "In an anime seasons view, display a dub tag in front of the season name."


# Crunchyroll Menue

Expand Down
8 changes: 8 additions & 0 deletions resources/language/resource.language.es_es/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ msgctxt "#30039"
msgid "In an anime seasons view, only display dubs in either Japanese, your CR language or any of your configured subtitle languages."
msgstr "En una vista de temporadas de anime, sólo se muestran los idiomas de audio en japonés, su idioma Crunchyroll o cualquiera de los idiomas de subtítulos configurados."

msgctxt "#30036"
msgid "Show dub language in Season View"
msgstr "Mostrar el idioma de doblaje en la vista de temporadas"

msgctxt "#30037"
msgid "In an anime seasons view, display a dub tag in front of the season name."
msgstr "En la vista de temporadas de un anime, muestra una etiqueta de doblaje delante del nombre de la temporada."


# Crunchyroll Menue

Expand Down
8 changes: 8 additions & 0 deletions resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ msgctxt "#30039"
msgid "In an anime seasons view, only display dubs in either Japanese, your CR language or any of your configured subtitle languages."
msgstr "Dans une vue de saisons d'anime, n'affichez que les langues audio en japonais, votre langue Crunchyroll ou l'une des langues de sous-titres que vous avez configurées."

msgctxt "#30036"
msgid "Show dub language in Season View"
msgstr "Afficher la langue du doublage dans la vue des saisons"

msgctxt "#30037"
msgid "In an anime seasons view, display a dub tag in front of the season name."
msgstr "Dans la vue des saisons d'un anime, afficher une étiquette de doublage devant le nom de la saison."


# Crunchyroll Menue
msgctxt "#30040"
Expand Down
7 changes: 7 additions & 0 deletions resources/language/resource.language.pt_br/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ msgctxt "#30039"
msgid "In an anime seasons view, only display dubs in either Japanese, your CR language or any of your configured subtitle languages."
msgstr "Em uma exibição de temporadas de anime, exiba apenas os idiomas de áudio em japonês, o idioma Crunchyroll ou qualquer um dos idiomas de legenda configurados."

msgctxt "#30036"
msgid "Show dub language in Season View"
msgstr "Mostrar o idioma da dublagem na visualização da temporada"

msgctxt "#30037"
msgid "In an anime seasons view, display a dub tag in front of the season name."
msgstr "Em uma visualização de temporadas de anime, exiba uma tag de dublagem na frente do nome da temporada."


# Crunchyroll Menue
Expand Down
47 changes: 42 additions & 5 deletions resources/lib/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,52 @@ def to_item(self, args: Args) -> xbmcgui.ListItem:

li = xbmcgui.ListItem()
li.setLabel(self.title)
li_info = li.getVideoInfoTag()

# if is a playable item, set some things
if hasattr(self, 'duration'):
li.setProperty("IsPlayable", "true")
li.setProperty('TotalTime', str(float(getattr(self, 'duration'))))
li_info.setDuration(int(getattr(self, 'duration')))
# set resume if not fully watched and playhead > x
if hasattr(self, 'playcount') and getattr(self, 'playcount') == 0:
if hasattr(self, 'playhead') and getattr(self, 'playhead') > 0:
resume = int(getattr(self, 'playhead') / getattr(self, 'duration') * 100)
if 5 <= resume <= 90:
li.setProperty('ResumeTime', str(float(getattr(self, 'playhead'))))
li_info.setResumePoint(float(getattr(self, 'playhead')), float(getattr(self, 'duration')))


li_info.setTitle(list_info.get('title'))
li_info.setTvShowTitle(list_info.get('tvshowtitle'))
li_info.setSeason(int(list_info.get('season')))
""" sometimes no explicit episode number is given: ['', 'OVA', 'SP']
sometimes it's a plain number, sometimes it's text
"""
if str(list_info.get('episode')).isnumeric():
li_info.setEpisode(int(list_info.get('episode')))
else:
li_info.setEpisode(0)
if list_info.get('plot'): # seasons don't have plots
li_info.setPlot(list_info.get('plot'))
li_info.setPlotOutline(list_info.get('plotoutline'))

# playhead -> see setResumePoint above
# duration -> see setDuration above
li_info.setPlaycount(int(list_info.get('playcount')))

# season_id -> not part of InfoTagVideo
# series_id -> not part of InfoTagVideo
# episode_id -> not part of InfoTagVideo
# stream_id -> not part of InfoTagVideo

if list_info.get('year'): # it's unlikely the other dates are given if year is missing
li_info.setYear(int(list_info.get('year')[0:3])) # only use first 4 digits in case of date
li_info.setFirstAired(list_info.get('aired'))
li_info.setPremiered(list_info.get('premiered'))

li_info.setRating(float(list_info.get('rating')))

li_info.setMediaType(list_info.get('mediatype'))

li.setInfo('video', list_info)
li.setArt({
"thumb": self.thumb or 'DefaultFolder.png',
'poster': self.poster or self.thumb or 'DefaultFolder.png',
Expand Down Expand Up @@ -265,7 +298,7 @@ def get_info(self, args: Args) -> Dict:
Crunchyroll XBMC
series collection
season season
episode episode
episode episode
"""


Expand Down Expand Up @@ -337,7 +370,11 @@ def __init__(self, data: dict):
super().__init__()

self.id = data.get("id")
self.title: str = data.get("title")
settings = xbmcaddon.Addon(id=re.sub(r"^plugin://([^/]+)/.*$", r"\1", sys.argv[0])).getSettings()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I personally would move that logic outside of this DTO to utils.get_listables_from_response .
Also, I think sometimes there already is a language thingy in front of the season name, not often, but sometimes it is. It might be worth checking for that with a regex and only add this if it doesn't exist already.

If you don't mind I'll cherry-pick that functionality from your code and implement it as described.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I don't mind at all.
I don't really like that functionality in there either, but I didn't figure out how to detect seasons in get_listables and that was the easiest way for me.

if settings.getBool("show_lang_in_seasons"):
self.title: str = '[' + data.get("audio_locale") + '] ' + data.get("title")
else:
self.title: str = data.get("title")
self.tvshowtitle: str = data.get("title")
self.series_id: str | None = data.get("series_id")
self.season_id: str | None = data.get("id")
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,5 @@ def highlight_list_item_title(list_item: xbmcgui.ListItem):

Used to highlight that item is already on watchlist
"""
list_item.setInfo('video', {'title': '[COLOR orange]' + list_item.getLabel() + '[/COLOR]'})
li_info = list_item.getVideoInfoTag()
li_info.setTitle('[COLOR orange]' + list_item.getLabel() + '[/COLOR]')
13 changes: 9 additions & 4 deletions resources/lib/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,24 @@ def add_item(

# create list item
li = xbmcgui.ListItem(label=info["title"], path=u)
li_info = li.getVideoInfoTag()

# get infoLabels
info_labels = make_info_label(args, info)

if is_folder:
# directory
info_labels["mediatype"] = "tvshow"
li.setInfo(mediatype, info_labels)
li_info.setTitle(info_labels.get('title'))
if info_labels.get('genre'):
li_info.setGenres([info_labels.get('genre')])
li_info.setMediaType('tvshow')
else:
# playable video
info_labels["mediatype"] = "episode"
li.setInfo(mediatype, info_labels)
li.setProperty("IsPlayable", "true")
li_info.setTitle(info_labels.get('title'))
if info_labels.get('genre'):
li_info.setGenres([info_labels.get('genre')])
li_info.setMediaType('episode')

# add context menu to jump to seasons xor episodes
# @todo: this only makes sense in some very specific places, we need a way to handle these better.
Expand Down
6 changes: 6 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
<default>true</default>
<control type="toggle"/>
</setting>

<setting id="show_lang_in_seasons" type="boolean" label="30036" help="30037">
<level>0</level>
<default>false</default>
<control type="toggle"/>
</setting>
</group>
</category>
<category id="playback_options" label="30220" help="">
Expand Down