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

feat: Upnext addon integration #45

Open
wants to merge 7 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Git repo: https://github.com/MrKrabat/plugin.video.crunchyroll
- [x] Optionally soft-subs only
- [x] Configure up to two languages for subtitles / dubs
- [x] Crunchylists support
- [x] UpNext addon integration

***

Expand Down
28 changes: 28 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ msgctxt "#30230"
msgid "Other"
msgstr "Sonstiges"

msgctxt "#30240"
msgid "Addons"
msgstr "Erweiterungen"

msgctxt "#30101"
msgid "Email"
msgstr "E-Mail"
Expand Down Expand Up @@ -296,3 +300,27 @@ msgstr "Es sind zu viele Streams aktiv. Bitte probiere es später noch einmal."
msgctxt "#30090"
msgid "No search results"
msgstr "Keine Suchergebnisse"

msgctxt "#30319"
msgid "UpNext fixed or unavailable end detection duration"
msgstr "Vorlaufzeit für UpNext wenn \"Statisch\" oder keine Credits/Vorschau"

msgctxt "#30300"
msgid "Show UpNext dialog at"
msgstr "UpNext Integration"

msgctxt "#30301"
msgid "credits start"
msgstr "Zu Beginn der Credits, wenn danach keine Vorschau kommt"
Copy link
Owner

Choose a reason for hiding this comment

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

Probably need to refine this, I wasn't sure what the english text was trying to tell me. :D

Copy link
Author

Choose a reason for hiding this comment

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

As I wrote in a previous comment, I change it to something more understandable.

In fact, it may be named like that (because, this is what it does):

"Show UpNext dialog at":

  • "credits start"
  • "preview start"
  • "fixed time before the end"
  • "never (disabled)"


msgctxt "#30302"
msgid "preview start"
msgstr "Zu Beginn der Vorschau"

msgctxt "#30303"
msgid "fixed time before the end"
msgstr "Statisch"

msgctxt "#30304"
msgid "never (disabled)"
msgstr "Deaktiviert"
30 changes: 29 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ msgctxt "#30230"
msgid "Other"
msgstr ""

msgctxt "#30240"
msgid "Addons"
msgstr ""

msgctxt "#30001"
msgid "Email"
msgstr ""
Expand Down Expand Up @@ -297,4 +301,28 @@ msgstr ""

msgctxt "#30090"
msgid "No search results"
msgstr "No search results"
msgstr "No search results"

msgctxt "#30319"
msgid "UpNext fixed or unavailable end detection duration"
msgstr ""

msgctxt "#30300"
msgid "Show UpNext dialog at"
msgstr ""

msgctxt "#30301"
msgid "credits start"
msgstr ""

msgctxt "#30302"
msgid "preview start"
msgstr ""

msgctxt "#30303"
msgid "fixed time before the end"
msgstr ""

msgctxt "#30304"
msgid "never (disabled)"
msgstr ""
30 changes: 29 additions & 1 deletion resources/language/resource.language.es_es/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ msgctxt "#30230"
msgid "Other"
msgstr "Otro"

msgctxt "#30240"
msgid "Addons"
msgstr ""

msgctxt "#30001"
msgid "Email"
msgstr "Email"
Expand Down Expand Up @@ -296,4 +300,28 @@ msgstr ""

msgctxt "#30090"
msgid "No search results"
msgstr ""
msgstr ""

msgctxt "#30319"
msgid "UpNext fixed or unavailable end detection duration"
msgstr ""

msgctxt "#30300"
msgid "Show UpNext dialog at"
msgstr ""

msgctxt "#30301"
msgid "credits start"
msgstr ""

msgctxt "#30302"
msgid "preview start"
msgstr ""

msgctxt "#30303"
msgid "fixed time before the end"
msgstr ""

msgctxt "#30304"
msgid "never (disabled)"
msgstr ""
44 changes: 36 additions & 8 deletions resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ msgstr "Se connecter"

msgctxt "#30210"
msgid "Languages"
msgstr "Lanagages"
msgstr "Langages"

msgctxt "#30220"
msgid "Playback"
Expand All @@ -31,6 +31,10 @@ msgctxt "#30230"
msgid "Other"
msgstr "Autre"

msgctxt "#30240"
msgid "Addons"
msgstr "Extensions"

msgctxt "#30001"
msgid "Email"
msgstr "Email"
Expand Down Expand Up @@ -69,7 +73,7 @@ msgstr "Passer"

msgctxt "#30020"
msgid "Subtitle Language"
msgstr "Language des sous titres"
msgstr "Langue des sous titres"

msgctxt "#30021"
msgid "English"
Expand Down Expand Up @@ -241,19 +245,19 @@ msgstr "Une erreur est survenue"

msgctxt "#30062"
msgid "You need to be logged in"
msgstr "Vus devez être connecté"
msgstr "Vous devez être connecté"

msgctxt "#30063"
msgid "You need to be a premium member"
msgstr "Voius devez être un membre premium"
msgstr "Vous devez être un membre premium"

msgctxt "#30064"
msgid "Failed to play video"
msgstr "Erreur de lecture vidéo"

msgctxt "#30065"
msgid "Do you want to continue watching at %s%%?"
msgstr "Voulez vous continuer à regarder depuis %s%% ?"
msgstr "Voulez-vous continuer à regarder depuis %s%% ?"

msgctxt "#30066"
msgid "If the video does not start wait 30 seconds for the fallback to start."
Expand All @@ -269,7 +273,7 @@ msgstr "Supprimer de la file d'attente"

msgctxt "#30069"
msgid "Alternative Subtitle Language"
msgstr "Langage de sous-titres alternatif"
msgstr "Langue de sous-titres alternatif"

msgctxt "#30070"
msgid "None"
Expand All @@ -289,8 +293,32 @@ msgstr "Choisissez votre profil"

msgctxt "#30080"
msgid "There are too many active streams. Please try again later."
msgstr ""
msgstr "Il y a trop de streams actifs. Ré-essayez plus tard."

msgctxt "#30090"
msgid "No search results"
msgstr ""
msgstr "Aucun résultat"

msgctxt "#30319"
msgid "UpNext fixed or unavailable end detection duration"
msgstr "Durée fixe ou de détection indisponible pour UpNext"

msgctxt "#30300"
msgid "Show UpNext dialog at"
msgstr "Afficher la fenêtre UpNext quand"

msgctxt "#30301"
msgid "credits start"
msgstr "le générique commence"

msgctxt "#30302"
msgid "preview start"
msgstr "la preview commence"

msgctxt "#30303"
msgid "fixed time before the end"
msgstr "une durée fixe avant la fin"

msgctxt "#30304"
msgid "never (disabled)"
msgstr "jamais (désactivé)"
30 changes: 29 additions & 1 deletion resources/language/resource.language.pt_br/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ msgctxt "#30230"
msgid "Other"
msgstr "Outros"

msgctxt "#30240"
msgid "Addons"
msgstr ""

msgctxt "#30001"
msgid "Username"
msgstr "E-mail"
Expand Down Expand Up @@ -293,4 +297,28 @@ msgstr "Muitas streams ativas. Por favor, tente mais tarde"

msgctxt "#30090"
msgid "No search results"
msgstr ""
msgstr ""

msgctxt "#30319"
msgid "UpNext fixed or unavailable end detection duration"
msgstr ""

msgctxt "#30300"
msgid "Show UpNext dialog at"
msgstr ""

msgctxt "#30301"
msgid "credits start"
msgstr ""

msgctxt "#30302"
msgid "preview start"
msgstr ""

msgctxt "#30303"
msgid "fixed time before the end"
msgstr ""

msgctxt "#30304"
msgid "never (disabled)"
msgstr ""
1 change: 1 addition & 0 deletions resources/lib/addons/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
79 changes: 79 additions & 0 deletions resources/lib/addons/upnext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# Crunchyroll
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from base64 import b64encode
from json import dumps
from typing import Optional

from resources.lib.model import Args, PlayableItem, SeriesData

from . import utils


def send_next_info(
args: Args,
current_episode: PlayableItem,
next_episode: PlayableItem,
play_url: str,
notification_offset: Optional[int] = None,
series: Optional[SeriesData] = None
):
"""
Notify next episode info to upnext.
See https://github.com/im85288/service.upnext/wiki/Integration#sending-data-to-up-next for implementation details.
"""
current_upnext_episode = UpnextEpisode(current_episode, series)
next_upnext_episode = UpnextEpisode(next_episode, series)
next_info = {
"current_episode": current_upnext_episode.__dict__,
"next_episode": next_upnext_episode.__dict__,
"play_url": play_url,
}
if notification_offset is not None:
next_info["notification_offset"] = notification_offset
upnext_signal(args.addon_id, next_info)


class UpnextEpisode:
def __init__(self, dto: PlayableItem, series_dto: Optional[SeriesData]):
self.episodeid: str | None = dto.episode_id
self.tvshowid: str | None = dto.series_id
self.title: str = dto.title_unformatted
self.art: dict = {
"thumb": dto.thumb,
}
if series_dto:
self.art.update({
# "tvshow.clearart": series_dto.clearart,
# "tvshow.clearlogo": series_dto.clearlogo,
"tvshow.fanart": series_dto.fanart,
"tvshow.landscape": series_dto.fanart,
"tvshow.poster": series_dto.poster,
})
self.season: int = dto.season
self.episode: str = dto.episode
self.showtitle: str = dto.tvshowtitle
self.plot: str = dto.plot
self.playcount: int = dto.playcount
# self.rating: str = dto.rating
self.firstaired: str = dto.year
self.runtime: int = dto.duration


def upnext_signal(sender, next_info):
"""Send upnext_data to Kodi using JSON RPC"""
data = [utils.to_unicode(b64encode(dumps(next_info).encode()))]
utils.notify(sender=sender + '.SIGNAL', message='upnext_data', data=data)
Loading