Skip to content

Commit

Permalink
0.2.1 add localization
Browse files Browse the repository at this point in the history
closes #1
  • Loading branch information
kuriho committed May 29, 2023
1 parent 2513059 commit b1e8a3a
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 23 deletions.
6 changes: 3 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<addon id="plugin.video.tver" name="TVer" version="0.2.0" provider-name="kuriho">
<addon id="plugin.video.tver" name="TVer" version="0.2.1" provider-name="kuriho">

<requires>
<import addon="xbmc.python" version="3.0.1" />
Expand All @@ -20,7 +20,7 @@
<assets>
<icon>icon.png</icon>
</assets>
<summary lang="ja_JP">TVer Addon</summary>
<description lang="ja_JP">TVer.jp + yt-dlp = ♥</description>
<summary lang="en">TVer Addon</summary>
<description lang="en">TVer.jp + yt-dlp = ♥</description>
</extension>
</addon>
2 changes: 1 addition & 1 deletion mylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def insert(self, type, content):
def get(self):
self.delete_expired()
mylist = self.select()
#todo: add settings

watched = [str(dict(parse_qsl(entry))['video']).split('/')[-1] for entry in Watcher().select_watched_from_list([get_url(action='play', video=URL_VIDEO_WEBSITE.format(item[1], item[0])) for item in mylist])]

episodes = []
Expand Down
14 changes: 7 additions & 7 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from mylist import MyList
from watcher import Watcher
from utils import log, showInfoNotification, check_if_kodi_supports_manifest, extract_info, extract_manifest_url_from_info, get_url, refresh, get_adaptive_type_from_url
from utils import log, show_info, check_if_kodi_supports_manifest, extract_info, extract_manifest_url_from_info, get_url, refresh, get_adaptive_type_from_url, localize

_HANDLE = int(sys.argv[1])

Expand All @@ -16,11 +16,11 @@ def list_videos(category):
xbmcplugin.setContent(_HANDLE, 'videos')

videos = []
context = ('マイリストに追加','mylist')
context = (localize(30021),'mylist')

if category == 'mylist':
videos = MyList().get()
context = ('マイリストから削除','delist')
context = (localize(30020),'delist')
elif category == 'watching':
videos = tver.get_watching_episodes()
else:
Expand Down Expand Up @@ -54,11 +54,11 @@ def get_categories():
cats = tver.get_categories()

if Watcher().is_watching():
cats.insert(0,("watching", "視聴中", None))
cats.insert(0,("watching", localize(30003), None))

mylist_pic = MyList().get_random_pic()
if mylist_pic:
cats.insert(0,("mylist", "マイリスト", mylist_pic))
cats.insert(0,("mylist", localize(30002), mylist_pic))

return cats

Expand Down Expand Up @@ -96,9 +96,9 @@ def play_video(video):
adaptive_type = get_adaptive_type_from_url(url)

if not url or not check_if_kodi_supports_manifest(adaptive_type):
err_msg = "Error: YT-DLP was not able to extract stream."
err_msg = localize(33000)
log(err_msg)
showInfoNotification(err_msg)
show_info(err_msg)
raise Exception(err_msg)

list_item = xbmcgui.ListItem(info['title'], path=url)
Expand Down
83 changes: 83 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Addon Name: TVer
# Addon id: plugin.video.tver
# Addon Provider: kuriho
msgid ""
msgstr ""
"Project-Id-Version: plugin.video.tver\n"
"Report-Msgid-Bugs-To: https://github.com/kuriho/plugin.video.tver/issues\n"
"POT-Creation-Date: 2023-05-29 10:48+0000\n"
"PO-Revision-Date: 2023-05-29 10:48+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Last-Translator: kuriho\n"

# folders
msgctxt "#30000"
msgid "TVer"
msgstr "TVer"

msgctxt "#30002"
msgid "My list"
msgstr "Meine Liste"

msgctxt "#30003"
msgid "Continue watching"
msgstr "Weitersehen"

msgctxt "#30005"
msgid "Variety"
msgstr "Varieté"

msgctxt "#30006"
msgid "Drama"
msgstr "Serie"

msgctxt "#30007"
msgid "Anime"
msgstr "Anime"

msgctxt "#30008"
msgid "Documentary"
msgstr "Dokumentarfilm"

msgctxt "#30009"
msgid "Sports"
msgstr "Sport"

msgctxt "#30010"
msgid "Others"
msgstr "Andere"

# context menus
msgctxt "#30020"
msgid "Remove from 'My list'"
msgstr "Von 'Meine Liste' entfernen"

msgctxt "#30021"
msgid "Add to 'My list'"
msgstr "Zu 'Meine Liste' hinzufügen"

# settings
msgctxt "#30050"
msgid "Cache"
msgstr "Cache"

msgctxt "#30051"
msgid "Clear thumbnail cache"
msgstr "Vorschaubilder Cache leeren"

msgctxt "#30052"
msgid "Clear TVer cache"
msgstr "TVer Cache leeren"

msgctxt "#30071"
msgid "Remove"
msgstr "Entfernen"

# messages
msgctxt "#33000"
msgid "failed to extract stream"
msgstr "Stream konnte nicht extrahiert werden"
83 changes: 83 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Addon Name: TVer
# Addon id: plugin.video.tver
# Addon Provider: kuriho
msgid ""
msgstr ""
"Project-Id-Version: plugin.video.tver\n"
"Report-Msgid-Bugs-To: https://github.com/kuriho/plugin.video.tver/issues\n"
"POT-Creation-Date: 2023-05-29 10:48+0000\n"
"PO-Revision-Date: 2023-05-29 10:48+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Last-Translator: kuriho\n"

# folders
msgctxt "#30000"
msgid "TVer"
msgstr ""

msgctxt "#30002"
msgid "My list"
msgstr ""

msgctxt "#30003"
msgid "Continue watching"
msgstr ""

msgctxt "#30005"
msgid "Variety"
msgstr ""

msgctxt "#30006"
msgid "Drama"
msgstr ""

msgctxt "#30007"
msgid "Anime"
msgstr ""

msgctxt "#30008"
msgid "Documentary"
msgstr ""

msgctxt "#30009"
msgid "Sports"
msgstr ""

msgctxt "#30010"
msgid "Others"
msgstr ""

# context menus
msgctxt "#30020"
msgid "Remove from 'My list'"
msgstr ""

msgctxt "#30021"
msgid "Add to 'My list'"
msgstr ""

# settings
msgctxt "#30050"
msgid "Cache"
msgstr ""

msgctxt "#30051"
msgid "Clear thumbnail cache"
msgstr ""

msgctxt "#30052"
msgid "Clear TVer cache"
msgstr ""

msgctxt "#30071"
msgid "Remove"
msgstr ""

# messages
msgctxt "#33000"
msgid "failed to extract stream"
msgstr ""
83 changes: 83 additions & 0 deletions resources/language/resource.language.ja_jp/strings.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Addon Name: TVer
# Addon id: plugin.video.tver
# Addon Provider: kuriho
msgid ""
msgstr ""
"Project-Id-Version: plugin.video.tver\n"
"Report-Msgid-Bugs-To: https://github.com/kuriho/plugin.video.tver/issues\n"
"POT-Creation-Date: 2023-05-29 10:38+0000\n"
"PO-Revision-Date: 2023-05-29 10:38+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ja\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Last-Translator: kuriho\n"

# folders
msgctxt "#30000"
msgid "TVer"
msgstr "ティーバー"

msgctxt "#30002"
msgid "My list"
msgstr "マイリスト"

msgctxt "#30003"
msgid "Continue watching"
msgstr "視聴中"

msgctxt "#30005"
msgid "Variety"
msgstr "バラエティ"

msgctxt "#30006"
msgid "Drama"
msgstr "ドラマ"

msgctxt "#30007"
msgid "Anime"
msgstr "アニメ"

msgctxt "#30008"
msgid "Documentary"
msgstr "ドキュメンタリー"

msgctxt "#30009"
msgid "Sports"
msgstr "スポーツ"

msgctxt "#30010"
msgid "Others"
msgstr "その他"

# context menus
msgctxt "#30020"
msgid "Remove from 'My list'"
msgstr "マイリストから削除"

msgctxt "#30021"
msgid "Add to 'My list'"
msgstr "マイリストに追加"

# settings
msgctxt "#30050"
msgid "Cache"
msgstr "キャッシュ"

msgctxt "#30051"
msgid "Clear thumbnail cache"
msgstr "サムネイルキャッシュをクリア"

msgctxt "#30052"
msgid "Clear TVer cache"
msgstr "ティーバーキャッシュをクリア"

msgctxt "#30071"
msgid "Remove"
msgstr "削除"

# messages
msgctxt "#33000"
msgid "failed to extract stream"
msgstr "ストリームの抽出に失敗しました"
12 changes: 6 additions & 6 deletions tver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
from cache import Cache
from watcher import Watcher
from utils import get_random_ua, strip_or_none, get_custom_img_path, find_episode
from utils import get_random_ua, strip_or_none, get_custom_img_path, find_episode, localize
from urllib.parse import parse_qsl

URL_TOKEN_SERVICE = 'https://platform-api.tver.jp/v2/api/platform_users/browser/create'
Expand All @@ -11,11 +11,11 @@
URL_VIDEO_PICTURE = 'https://statics.tver.jp/images/content/thumbnail/{}/small/{}.jpg'

CATEGORIES = [
("variety","バラエティ", get_custom_img_path("variety.jpg")),
("drama","ドラマ", get_custom_img_path("drama.jpg")),
("anime","アニメ", get_custom_img_path("anime.jpg")),
("documentary","ドキュメンタリー", get_custom_img_path("documentary.jpg")),
("sports","スポーツ", get_custom_img_path("sports.jpg")),
("variety",localize(30005), get_custom_img_path("variety.jpg")),
("drama",localize(30006), get_custom_img_path("drama.jpg")),
("anime",localize(30007), get_custom_img_path("anime.jpg")),
("documentary",localize(30008), get_custom_img_path("documentary.jpg")),
("sports",localize(30009), get_custom_img_path("sports.jpg")),
]

def get_categories():
Expand Down
14 changes: 8 additions & 6 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ def log(msg, level=xbmc.LOGINFO):
addonID = addon.getAddonInfo('id')
xbmc.log('%s: %s' % (addonID, msg), level)

def showInfoNotification(message):
xbmcgui.Dialog().notification("TVer", message, xbmcgui.NOTIFICATION_INFO, 5000)
def show_info(message):
xbmcgui.Dialog().notification(localize(30000), message, xbmcgui.NOTIFICATION_INFO, 5000)


def showErrorNotification(message):
xbmcgui.Dialog().notification("TVer", message, xbmcgui.NOTIFICATION_ERROR, 5000)
def show_error(message):
xbmcgui.Dialog().notification(localize(30000), message, xbmcgui.NOTIFICATION_ERROR, 5000)

def get_random_ua():
return user_agents[randint(0, len(user_agents) - 1)]
Expand Down Expand Up @@ -139,4 +138,7 @@ def find_episode(full_cache, episode_id):
return episode_json

def refresh():
xbmc.executebuiltin("Container.Refresh")
xbmc.executebuiltin("Container.Refresh")

def localize(string_id):
return xbmcaddon.Addon().getLocalizedString(string_id)

0 comments on commit b1e8a3a

Please sign in to comment.