Compare commits
7 Commits
v0.1.77.0-
...
v0.1.80.5-
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b9ba6a01a | |||
| 811f617ff7 | |||
| e4828dedd0 | |||
| 1969c21c11 | |||
| f8e59acd94 | |||
| 0a161fd8c6 | |||
| caa4a4a0e2 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -19,3 +19,7 @@ __pycache__/
|
|||||||
|
|
||||||
# Plugin runtime caches
|
# Plugin runtime caches
|
||||||
/addon/plugins/*_cache.json
|
/addon/plugins/*_cache.json
|
||||||
|
|
||||||
|
# Projektdokumentation (lokal)
|
||||||
|
/PROJECT_INDEX.md
|
||||||
|
/FUNCTION_MAP.md
|
||||||
|
|||||||
@@ -1,3 +1,31 @@
|
|||||||
|
## 0.1.80.0-dev - 2026-03-13
|
||||||
|
|
||||||
|
- dev: YouTube-Plugin: yt-dlp Suche, Bug-Fix Any-Import
|
||||||
|
|
||||||
|
## 0.1.79.5-dev - 2026-03-11
|
||||||
|
|
||||||
|
- dev: Changelog-Hook auf prepare-commit-msg umgestellt
|
||||||
|
|
||||||
|
## 0.1.79.0-dev - 2026-03-11
|
||||||
|
|
||||||
|
- dev: TMDB API-Key automatisch aus Kodi-Scraper ermitteln
|
||||||
|
|
||||||
|
## 0.1.78.5-dev - 2026-03-11
|
||||||
|
|
||||||
|
- dev: Uhrzeit aus Episodentitel entfernen, tvshow-Mediatype fix
|
||||||
|
|
||||||
|
## 0.1.78.0-dev - 2026-03-11
|
||||||
|
|
||||||
|
- dev: Trakt-Scrobbling fuer alle Wiedergabe-Pfade
|
||||||
|
|
||||||
|
## 0.1.77.5-dev - 2026-03-10
|
||||||
|
|
||||||
|
- dev: Max. Eintraege pro Seite Setting pro Plugin
|
||||||
|
|
||||||
|
## 0.1.77.0-dev - 2026-03-10
|
||||||
|
|
||||||
|
- dev: Changelog-Dialog nur anzeigen wenn Eintrag vorhanden
|
||||||
|
|
||||||
## 0.1.76.5-dev - 2026-03-10
|
## 0.1.76.5-dev - 2026-03-10
|
||||||
|
|
||||||
- dev: Versionsfilter fuer 4-teilige Versionsnummern korrigiert
|
- dev: Versionsfilter fuer 4-teilige Versionsnummern korrigiert
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<addon id="plugin.video.viewit" name="ViewIt" version="0.1.77.0-dev" provider-name="ViewIt">
|
<addon id="plugin.video.viewit" name="ViewIt" version="0.1.80.5-dev" provider-name="ViewIt">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="3.0.0" />
|
<import addon="xbmc.python" version="3.0.0" />
|
||||||
<import addon="script.module.requests" />
|
<import addon="script.module.requests" />
|
||||||
<import addon="script.module.beautifulsoup4" />
|
<import addon="script.module.beautifulsoup4" />
|
||||||
<import addon="script.module.resolveurl" version="5.1.0" />
|
<import addon="script.module.resolveurl" version="5.1.0" />
|
||||||
<import addon="script.trakt" optional="true" />
|
<import addon="script.trakt" optional="true" />
|
||||||
|
<import addon="script.module.yt-dlp" optional="true" />
|
||||||
</requires>
|
</requires>
|
||||||
<extension point="xbmc.python.pluginsource" library="default.py">
|
<extension point="xbmc.python.pluginsource" library="default.py">
|
||||||
<provides>video</provides>
|
<provides>video</provides>
|
||||||
|
|||||||
@@ -52,6 +52,24 @@ def _require_init() -> None:
|
|||||||
print("[ViewIT/metadata] WARNUNG: metadata.init() wurde nicht aufgerufen – Metadaten-Funktionen arbeiten mit Standardwerten!", file=sys.stderr)
|
print("[ViewIT/metadata] WARNUNG: metadata.init() wurde nicht aufgerufen – Metadaten-Funktionen arbeiten mit Standardwerten!", file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_tmdb_api_key(user_key: str) -> str:
|
||||||
|
"""Key aus ViewIT-Settings, installiertem Kodi-Scraper oder Community-Fallback."""
|
||||||
|
if user_key:
|
||||||
|
return user_key
|
||||||
|
if xbmcaddon:
|
||||||
|
for addon_id in (
|
||||||
|
"metadata.tvshows.themoviedb.org.python",
|
||||||
|
"metadata.themoviedb.org.python",
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
key = xbmcaddon.Addon(addon_id).getSetting("tmdb_apikey")
|
||||||
|
if key:
|
||||||
|
return key
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
return "80246691939720672db3fc71c74e0ef2"
|
||||||
|
|
||||||
|
|
||||||
def init(
|
def init(
|
||||||
*,
|
*,
|
||||||
get_setting_string: Callable[[str], str],
|
get_setting_string: Callable[[str], str],
|
||||||
@@ -153,7 +171,7 @@ def tmdb_labels_and_art(title: str) -> tuple[dict[str, str], dict[str, str], lis
|
|||||||
art: dict[str, str] = {}
|
art: dict[str, str] = {}
|
||||||
cast: list[TmdbCastMember] = []
|
cast: list[TmdbCastMember] = []
|
||||||
query = (title or "").strip()
|
query = (title or "").strip()
|
||||||
api_key = _get_setting_string("tmdb_api_key").strip()
|
api_key = _resolve_tmdb_api_key(_get_setting_string("tmdb_api_key").strip())
|
||||||
log_requests = _get_setting_bool("tmdb_log_requests", default=False)
|
log_requests = _get_setting_bool("tmdb_log_requests", default=False)
|
||||||
log_responses = _get_setting_bool("tmdb_log_responses", default=False)
|
log_responses = _get_setting_bool("tmdb_log_responses", default=False)
|
||||||
if api_key:
|
if api_key:
|
||||||
@@ -295,7 +313,7 @@ def tmdb_episode_labels_and_art(*, title: str, season_label: str, episode_label:
|
|||||||
season_key = (tmdb_id, season_number, language, flags)
|
season_key = (tmdb_id, season_number, language, flags)
|
||||||
cached_season = tmdb_cache_get(_TMDB_SEASON_CACHE, season_key)
|
cached_season = tmdb_cache_get(_TMDB_SEASON_CACHE, season_key)
|
||||||
if cached_season is None:
|
if cached_season is None:
|
||||||
api_key = _get_setting_string("tmdb_api_key").strip()
|
api_key = _resolve_tmdb_api_key(_get_setting_string("tmdb_api_key").strip())
|
||||||
if not api_key:
|
if not api_key:
|
||||||
return {"title": episode_label}, {}
|
return {"title": episode_label}, {}
|
||||||
log_requests = _get_setting_bool("tmdb_log_requests", default=False)
|
log_requests = _get_setting_bool("tmdb_log_requests", default=False)
|
||||||
@@ -358,7 +376,7 @@ def tmdb_episode_cast(*, title: str, season_label: str, episode_label: str) -> l
|
|||||||
if cached is not None:
|
if cached is not None:
|
||||||
return list(cached)
|
return list(cached)
|
||||||
|
|
||||||
api_key = _get_setting_string("tmdb_api_key").strip()
|
api_key = _resolve_tmdb_api_key(_get_setting_string("tmdb_api_key").strip())
|
||||||
if not api_key:
|
if not api_key:
|
||||||
tmdb_cache_set(_TMDB_EPISODE_CAST_CACHE, cache_key, [])
|
tmdb_cache_set(_TMDB_EPISODE_CAST_CACHE, cache_key, [])
|
||||||
return []
|
return []
|
||||||
@@ -398,7 +416,7 @@ def tmdb_season_labels_and_art(
|
|||||||
show_plot = _get_setting_bool("tmdb_show_plot", default=True)
|
show_plot = _get_setting_bool("tmdb_show_plot", default=True)
|
||||||
show_art = _get_setting_bool("tmdb_show_art", default=True)
|
show_art = _get_setting_bool("tmdb_show_art", default=True)
|
||||||
flags = f"p{int(show_plot)}a{int(show_art)}"
|
flags = f"p{int(show_plot)}a{int(show_art)}"
|
||||||
api_key = _get_setting_string("tmdb_api_key").strip()
|
api_key = _resolve_tmdb_api_key(_get_setting_string("tmdb_api_key").strip())
|
||||||
log_requests = _get_setting_bool("tmdb_log_requests", default=False)
|
log_requests = _get_setting_bool("tmdb_log_requests", default=False)
|
||||||
log_responses = _get_setting_bool("tmdb_log_responses", default=False)
|
log_responses = _get_setting_bool("tmdb_log_responses", default=False)
|
||||||
log_fn = tmdb_file_log if (log_requests or log_responses) else None
|
log_fn = tmdb_file_log if (log_requests or log_responses) else None
|
||||||
|
|||||||
151
addon/default.py
151
addon/default.py
@@ -1209,6 +1209,7 @@ UPDATE_HTTP_TIMEOUT_SEC = 8
|
|||||||
UPDATE_ADDON_ID = "plugin.video.viewit"
|
UPDATE_ADDON_ID = "plugin.video.viewit"
|
||||||
RESOLVEURL_ADDON_ID = "script.module.resolveurl"
|
RESOLVEURL_ADDON_ID = "script.module.resolveurl"
|
||||||
RESOLVEURL_AUTO_INSTALL_INTERVAL_SEC = 6 * 60 * 60
|
RESOLVEURL_AUTO_INSTALL_INTERVAL_SEC = 6 * 60 * 60
|
||||||
|
YTDLP_ADDON_ID = "script.module.yt-dlp"
|
||||||
|
|
||||||
|
|
||||||
def _selected_update_channel() -> int:
|
def _selected_update_channel() -> int:
|
||||||
@@ -1681,6 +1682,106 @@ def _maybe_auto_install_resolveurl(action: str | None) -> None:
|
|||||||
_ensure_resolveurl_installed(force=False, silent=True)
|
_ensure_resolveurl_installed(force=False, silent=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _sync_tmdb_active_key_setting() -> None:
|
||||||
|
from core.metadata import _resolve_tmdb_api_key
|
||||||
|
raw_key = _get_setting_string("tmdb_api_key").strip()
|
||||||
|
active_key = _resolve_tmdb_api_key(raw_key)
|
||||||
|
if active_key:
|
||||||
|
masked = active_key[:6] + "…" + active_key[-4:] if len(active_key) > 10 else active_key
|
||||||
|
else:
|
||||||
|
masked = "(kein)"
|
||||||
|
_set_setting_string("tmdb_api_key_active", masked)
|
||||||
|
|
||||||
|
|
||||||
|
def _sync_ytdlp_status_setting() -> None:
|
||||||
|
status = "Installiert" if _is_addon_installed(YTDLP_ADDON_ID) else "Fehlt"
|
||||||
|
_set_setting_string("ytdlp_status", status)
|
||||||
|
|
||||||
|
|
||||||
|
def _fetch_ytdlp_zip_url() -> str:
|
||||||
|
"""Ermittelt die aktuellste ZIP-URL fuer script.module.yt-dlp von GitHub."""
|
||||||
|
api_url = "https://api.github.com/repos/lekma/script.module.yt-dlp/releases/latest"
|
||||||
|
try:
|
||||||
|
data = json.loads(_read_binary_url(api_url, timeout=10).decode("utf-8"))
|
||||||
|
for asset in data.get("assets", []):
|
||||||
|
url = asset.get("browser_download_url", "")
|
||||||
|
if url.endswith(".zip"):
|
||||||
|
return url
|
||||||
|
except Exception as exc:
|
||||||
|
_log(f"yt-dlp Release-URL nicht ermittelbar: {exc}", xbmc.LOGWARNING)
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def _install_ytdlp_from_zip(zip_url: str) -> bool:
|
||||||
|
"""Laedt script.module.yt-dlp ZIP von GitHub und entpackt es in den Addons-Ordner."""
|
||||||
|
try:
|
||||||
|
zip_bytes = _read_binary_url(zip_url, timeout=60)
|
||||||
|
except Exception as exc:
|
||||||
|
_log(f"yt-dlp ZIP-Download fehlgeschlagen: {exc}", xbmc.LOGWARNING)
|
||||||
|
return False
|
||||||
|
if xbmcvfs is None:
|
||||||
|
return False
|
||||||
|
addons_root = xbmcvfs.translatePath("special://home/addons")
|
||||||
|
addons_root_real = os.path.realpath(addons_root)
|
||||||
|
try:
|
||||||
|
with zipfile.ZipFile(io.BytesIO(zip_bytes)) as archive:
|
||||||
|
for member in archive.infolist():
|
||||||
|
name = str(member.filename or "")
|
||||||
|
if not name or name.endswith("/"):
|
||||||
|
continue
|
||||||
|
target = os.path.realpath(os.path.join(addons_root, name))
|
||||||
|
if not target.startswith(addons_root_real + os.sep):
|
||||||
|
continue
|
||||||
|
os.makedirs(os.path.dirname(target), exist_ok=True)
|
||||||
|
with archive.open(member, "r") as src, open(target, "wb") as dst:
|
||||||
|
dst.write(src.read())
|
||||||
|
except Exception as exc:
|
||||||
|
_log(f"yt-dlp Entpacken fehlgeschlagen: {exc}", xbmc.LOGWARNING)
|
||||||
|
return False
|
||||||
|
builtin = getattr(xbmc, "executebuiltin", None)
|
||||||
|
if callable(builtin):
|
||||||
|
builtin("UpdateLocalAddons")
|
||||||
|
return _is_addon_installed(YTDLP_ADDON_ID)
|
||||||
|
|
||||||
|
|
||||||
|
def _ensure_ytdlp_installed(*, force: bool, silent: bool) -> bool:
|
||||||
|
if _is_addon_installed(YTDLP_ADDON_ID):
|
||||||
|
_sync_ytdlp_status_setting()
|
||||||
|
return True
|
||||||
|
|
||||||
|
zip_url = _fetch_ytdlp_zip_url()
|
||||||
|
if not zip_url:
|
||||||
|
_sync_ytdlp_status_setting()
|
||||||
|
if not silent:
|
||||||
|
xbmcgui.Dialog().notification(
|
||||||
|
"yt-dlp",
|
||||||
|
"Aktuelle Version nicht ermittelbar (GitHub nicht erreichbar?).",
|
||||||
|
xbmcgui.NOTIFICATION_ERROR,
|
||||||
|
5000,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
ok = _install_ytdlp_from_zip(zip_url)
|
||||||
|
_sync_ytdlp_status_setting()
|
||||||
|
|
||||||
|
if not silent:
|
||||||
|
if ok:
|
||||||
|
xbmcgui.Dialog().notification(
|
||||||
|
"yt-dlp",
|
||||||
|
"script.module.yt-dlp ist installiert.",
|
||||||
|
xbmcgui.NOTIFICATION_INFO,
|
||||||
|
4000,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
xbmcgui.Dialog().notification(
|
||||||
|
"yt-dlp",
|
||||||
|
"Installation fehlgeschlagen.",
|
||||||
|
xbmcgui.NOTIFICATION_ERROR,
|
||||||
|
5000,
|
||||||
|
)
|
||||||
|
return ok
|
||||||
|
|
||||||
|
|
||||||
def _sync_update_version_settings() -> None:
|
def _sync_update_version_settings() -> None:
|
||||||
addon_version = _installed_addon_version_from_disk()
|
addon_version = _installed_addon_version_from_disk()
|
||||||
if addon_version == "0.0.0":
|
if addon_version == "0.0.0":
|
||||||
@@ -1692,7 +1793,9 @@ def _sync_update_version_settings() -> None:
|
|||||||
addon_version = "0.0.0"
|
addon_version = "0.0.0"
|
||||||
_set_setting_string("update_installed_version", addon_version)
|
_set_setting_string("update_installed_version", addon_version)
|
||||||
_sync_resolveurl_status_setting()
|
_sync_resolveurl_status_setting()
|
||||||
|
_sync_ytdlp_status_setting()
|
||||||
_sync_update_channel_status_settings()
|
_sync_update_channel_status_settings()
|
||||||
|
_sync_tmdb_active_key_setting()
|
||||||
|
|
||||||
|
|
||||||
def _show_root_menu() -> None:
|
def _show_root_menu() -> None:
|
||||||
@@ -3176,8 +3279,9 @@ def _show_popular(plugin_name: str | None = None, page: int = 1) -> None:
|
|||||||
|
|
||||||
def _show_new_titles(plugin_name: str, page: int = 1, *, action_name: str = "new_titles") -> None:
|
def _show_new_titles(plugin_name: str, page: int = 1, *, action_name: str = "new_titles") -> None:
|
||||||
handle = _get_handle()
|
handle = _get_handle()
|
||||||
page_size = LIST_PAGE_SIZE
|
|
||||||
page = max(1, int(page or 1))
|
page = max(1, int(page or 1))
|
||||||
|
max_items_key = f"{(plugin_name or '').strip().casefold()}_max_page_items"
|
||||||
|
page_size = _get_setting_int(max_items_key, default=15) or LIST_PAGE_SIZE
|
||||||
|
|
||||||
plugin_name = (plugin_name or "").strip()
|
plugin_name = (plugin_name or "").strip()
|
||||||
plugin = _discover_plugins().get(plugin_name)
|
plugin = _discover_plugins().get(plugin_name)
|
||||||
@@ -3218,6 +3322,8 @@ def _show_new_titles(plugin_name: str, page: int = 1, *, action_name: str = "new
|
|||||||
xbmcplugin.endOfDirectory(handle)
|
xbmcplugin.endOfDirectory(handle)
|
||||||
return
|
return
|
||||||
page_items = [str(t).strip() for t in page_items if t and str(t).strip()]
|
page_items = [str(t).strip() for t in page_items if t and str(t).strip()]
|
||||||
|
if page_size > 0 and len(page_items) > page_size:
|
||||||
|
page_items = page_items[:page_size]
|
||||||
page_items.sort(key=lambda value: value.casefold())
|
page_items.sort(key=lambda value: value.casefold())
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@@ -3284,15 +3390,16 @@ def _show_new_titles(plugin_name: str, page: int = 1, *, action_name: str = "new
|
|||||||
meta = plugin_meta.get(title)
|
meta = plugin_meta.get(title)
|
||||||
info_labels, art, cast = _merge_metadata(title, tmdb_info, tmdb_art, tmdb_cast, meta)
|
info_labels, art, cast = _merge_metadata(title, tmdb_info, tmdb_art, tmdb_cast, meta)
|
||||||
info_labels = dict(info_labels or {})
|
info_labels = dict(info_labels or {})
|
||||||
info_labels.setdefault("mediatype", "movie")
|
is_direct_play = bool(
|
||||||
|
plugin_name.casefold() == "einschalten"
|
||||||
|
and _get_setting_bool("einschalten_enable_playback", default=False)
|
||||||
|
)
|
||||||
|
info_labels.setdefault("mediatype", "movie" if is_direct_play else "tvshow")
|
||||||
playstate = _title_playstate(plugin_name, title)
|
playstate = _title_playstate(plugin_name, title)
|
||||||
info_labels = _apply_playstate_to_info(dict(info_labels), playstate)
|
info_labels = _apply_playstate_to_info(dict(info_labels), playstate)
|
||||||
display_label = _label_with_duration(title, info_labels)
|
display_label = _label_with_duration(title, info_labels)
|
||||||
display_label = _label_with_playstate(display_label, playstate)
|
display_label = _label_with_playstate(display_label, playstate)
|
||||||
direct_play = bool(
|
direct_play = is_direct_play
|
||||||
plugin_name.casefold() == "einschalten"
|
|
||||||
and _get_setting_bool("einschalten_enable_playback", default=False)
|
|
||||||
)
|
|
||||||
_add_directory_item(
|
_add_directory_item(
|
||||||
handle,
|
handle,
|
||||||
display_label,
|
display_label,
|
||||||
@@ -3378,8 +3485,6 @@ def _show_latest_episodes(plugin_name: str, page: int = 1) -> None:
|
|||||||
playstate = _get_playstate(key)
|
playstate = _get_playstate(key)
|
||||||
|
|
||||||
label = f"{title} - S{season_number:02d}E{episode_number:02d}"
|
label = f"{title} - S{season_number:02d}E{episode_number:02d}"
|
||||||
if airdate:
|
|
||||||
label = f"{label} ({airdate})"
|
|
||||||
label = _label_with_playstate(label, playstate)
|
label = _label_with_playstate(label, playstate)
|
||||||
|
|
||||||
info_labels: dict[str, object] = {
|
info_labels: dict[str, object] = {
|
||||||
@@ -4119,15 +4224,14 @@ def _play_episode(
|
|||||||
title_key = (title or "").strip().casefold()
|
title_key = (title or "").strip().casefold()
|
||||||
_tmdb_id = _tmdb_cache_get(_TMDB_ID_CACHE, title_key, 0)
|
_tmdb_id = _tmdb_cache_get(_TMDB_ID_CACHE, title_key, 0)
|
||||||
_imdb_id = ""
|
_imdb_id = ""
|
||||||
trakt_media: dict[str, object] | None = None
|
_kind = _tmdb_cache_get(_MEDIA_TYPE_CACHE, title_key, "tv") if _tmdb_id else "tv"
|
||||||
if _tmdb_id:
|
if _tmdb_id:
|
||||||
_kind = _tmdb_cache_get(_MEDIA_TYPE_CACHE, title_key, "tv")
|
|
||||||
_imdb_id = _fetch_and_cache_imdb_id(title_key, _tmdb_id, _kind)
|
_imdb_id = _fetch_and_cache_imdb_id(title_key, _tmdb_id, _kind)
|
||||||
_set_trakt_ids_property(title, _tmdb_id, _imdb_id)
|
_set_trakt_ids_property(title, _tmdb_id, _imdb_id)
|
||||||
trakt_media = {
|
trakt_media: dict[str, object] = {
|
||||||
"title": title, "tmdb_id": _tmdb_id, "imdb_id": _imdb_id, "kind": _kind,
|
"title": title, "tmdb_id": _tmdb_id, "imdb_id": _imdb_id, "kind": _kind,
|
||||||
"season": season_number or 0, "episode": episode_number or 0,
|
"season": season_number or 0, "episode": episode_number or 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
_play_final_link(
|
_play_final_link(
|
||||||
final_link,
|
final_link,
|
||||||
@@ -4231,6 +4335,19 @@ def _play_episode_url(
|
|||||||
if episode_number > 0:
|
if episode_number > 0:
|
||||||
info_labels["episode"] = str(episode_number)
|
info_labels["episode"] = str(episode_number)
|
||||||
display_title = _label_with_duration(display_title, info_labels)
|
display_title = _label_with_duration(display_title, info_labels)
|
||||||
|
|
||||||
|
title_key = (title or "").strip().casefold()
|
||||||
|
_tmdb_id = _tmdb_cache_get(_TMDB_ID_CACHE, title_key, 0)
|
||||||
|
_imdb_id = ""
|
||||||
|
_kind = _tmdb_cache_get(_MEDIA_TYPE_CACHE, title_key, "tv") if _tmdb_id else "tv"
|
||||||
|
if _tmdb_id:
|
||||||
|
_imdb_id = _fetch_and_cache_imdb_id(title_key, _tmdb_id, _kind)
|
||||||
|
_set_trakt_ids_property(title, _tmdb_id, _imdb_id)
|
||||||
|
trakt_media: dict[str, object] = {
|
||||||
|
"title": title, "tmdb_id": _tmdb_id, "imdb_id": _imdb_id, "kind": _kind,
|
||||||
|
"season": season_number or 0, "episode": episode_number or 0,
|
||||||
|
}
|
||||||
|
|
||||||
_play_final_link(
|
_play_final_link(
|
||||||
final_link,
|
final_link,
|
||||||
display_title=display_title,
|
display_title=display_title,
|
||||||
@@ -4238,6 +4355,7 @@ def _play_episode_url(
|
|||||||
art=art,
|
art=art,
|
||||||
cast=cast,
|
cast=cast,
|
||||||
resolve_handle=resolve_handle,
|
resolve_handle=resolve_handle,
|
||||||
|
trakt_media=trakt_media,
|
||||||
)
|
)
|
||||||
_track_playback_and_update_state_async(
|
_track_playback_and_update_state_async(
|
||||||
_playstate_key(plugin_name=plugin_name, title=title, season=season_label, episode=episode_label)
|
_playstate_key(plugin_name=plugin_name, title=title, season=season_label, episode=episode_label)
|
||||||
@@ -4977,6 +5095,11 @@ def _route_install_resolveurl(params: dict[str, str]) -> None:
|
|||||||
_ensure_resolveurl_installed(force=True, silent=False)
|
_ensure_resolveurl_installed(force=True, silent=False)
|
||||||
|
|
||||||
|
|
||||||
|
@_router.route("install_ytdlp")
|
||||||
|
def _route_install_ytdlp(params: dict[str, str]) -> None:
|
||||||
|
_ensure_ytdlp_installed(force=True, silent=False)
|
||||||
|
|
||||||
|
|
||||||
@_router.route("choose_source")
|
@_router.route("choose_source")
|
||||||
def _route_choose_source(params: dict[str, str]) -> None:
|
def _route_choose_source(params: dict[str, str]) -> None:
|
||||||
_show_choose_source(params.get("title", ""), params.get("plugins", ""))
|
_show_choose_source(params.get("title", ""), params.get("plugins", ""))
|
||||||
|
|||||||
270
addon/plugins/youtube_plugin.py
Normal file
270
addon/plugins/youtube_plugin.py
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
"""YouTube Plugin fuer ViewIT.
|
||||||
|
|
||||||
|
Suche und Wiedergabe von YouTube-Videos via HTML-Scraping und yt-dlp.
|
||||||
|
Benoetigt script.module.yt-dlp (optional).
|
||||||
|
|
||||||
|
Video-Eintraege werden als "Titel||VIDEO_ID" kodiert.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
from typing import Any, Callable, Dict, List, Optional, Set
|
||||||
|
|
||||||
|
try:
|
||||||
|
import requests
|
||||||
|
except ImportError:
|
||||||
|
requests = None # type: ignore
|
||||||
|
|
||||||
|
from plugin_interface import BasisPlugin
|
||||||
|
from plugin_helpers import log_error
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Konstanten
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
DEFAULT_TIMEOUT = 20
|
||||||
|
_SEP = "||" # Trennzeichen zwischen Titel und Video-ID
|
||||||
|
|
||||||
|
BASE_URL = "https://www.youtube.com"
|
||||||
|
|
||||||
|
HEADERS = {
|
||||||
|
"User-Agent": (
|
||||||
|
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
|
||||||
|
"(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||||
|
),
|
||||||
|
"Accept-Language": "de-DE,de;q=0.9,en;q=0.8",
|
||||||
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressCallback = Optional[Callable[[str, Optional[int]], Any]]
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Hilfsfunktionen
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def _encode(title: str, video_id: str) -> str:
|
||||||
|
return f"{title}{_SEP}{video_id}"
|
||||||
|
|
||||||
|
|
||||||
|
def _decode_id(entry: str) -> Optional[str]:
|
||||||
|
"""Extrahiert Video-ID aus einem kodierten Eintrag."""
|
||||||
|
if _SEP in entry:
|
||||||
|
return entry.split(_SEP, 1)[1].strip()
|
||||||
|
# Fallback: 11-Zeichen YouTube-ID am Ende
|
||||||
|
m = re.search(r"([A-Za-z0-9_-]{11})$", entry)
|
||||||
|
return m.group(1) if m else None
|
||||||
|
|
||||||
|
|
||||||
|
def _decode_title(entry: str) -> str:
|
||||||
|
if _SEP in entry:
|
||||||
|
return entry.split(_SEP, 1)[0].strip()
|
||||||
|
return entry
|
||||||
|
|
||||||
|
|
||||||
|
def _get_session() -> Any:
|
||||||
|
try:
|
||||||
|
from http_session_pool import get_requests_session
|
||||||
|
return get_requests_session("youtube", headers=HEADERS)
|
||||||
|
except Exception:
|
||||||
|
if requests:
|
||||||
|
s = requests.Session()
|
||||||
|
s.headers.update(HEADERS)
|
||||||
|
return s
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_yt_initial_data(html: str) -> Optional[dict]:
|
||||||
|
"""Extrahiert ytInitialData JSON aus dem HTML-Source."""
|
||||||
|
m = re.search(r"var ytInitialData\s*=\s*(\{.*?\});\s*(?:var |</script>)", html, re.DOTALL)
|
||||||
|
if not m:
|
||||||
|
# Alternativer Pattern
|
||||||
|
m = re.search(r"ytInitialData\s*=\s*(\{.+?\})\s*;", html, re.DOTALL)
|
||||||
|
if not m:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
return json.loads(m.group(1))
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _videos_from_search_data(data: dict) -> List[str]:
|
||||||
|
"""Extrahiert Video-Eintraege aus ytInitialData (Suchergebnisse)."""
|
||||||
|
results: List[str] = []
|
||||||
|
try:
|
||||||
|
contents = (
|
||||||
|
data
|
||||||
|
.get("contents", {})
|
||||||
|
.get("twoColumnSearchResultsRenderer", {})
|
||||||
|
.get("primaryContents", {})
|
||||||
|
.get("sectionListRenderer", {})
|
||||||
|
.get("contents", [])
|
||||||
|
)
|
||||||
|
for section in contents:
|
||||||
|
items = (
|
||||||
|
section
|
||||||
|
.get("itemSectionRenderer", {})
|
||||||
|
.get("contents", [])
|
||||||
|
)
|
||||||
|
for item in items:
|
||||||
|
vr = item.get("videoRenderer") or item.get("compactVideoRenderer")
|
||||||
|
if not vr:
|
||||||
|
continue
|
||||||
|
video_id = vr.get("videoId", "").strip()
|
||||||
|
if not video_id:
|
||||||
|
continue
|
||||||
|
title_runs = vr.get("title", {}).get("runs", [])
|
||||||
|
title = "".join(r.get("text", "") for r in title_runs).strip()
|
||||||
|
if not title:
|
||||||
|
title = vr.get("title", {}).get("simpleText", "").strip()
|
||||||
|
if title and video_id:
|
||||||
|
results.append(_encode(title, video_id))
|
||||||
|
except Exception as exc:
|
||||||
|
log_error(f"[YouTube] _videos_from_search_data Fehler: {exc}")
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def _search_with_ytdlp(query: str, count: int = 20) -> List[str]:
|
||||||
|
"""Sucht YouTube-Videos via yt-dlp ytsearch-Extraktor."""
|
||||||
|
try:
|
||||||
|
from yt_dlp import YoutubeDL # type: ignore
|
||||||
|
except ImportError:
|
||||||
|
return []
|
||||||
|
ydl_opts = {"quiet": True, "no_warnings": True, "extract_flat": True}
|
||||||
|
try:
|
||||||
|
with YoutubeDL(ydl_opts) as ydl:
|
||||||
|
info = ydl.extract_info(f"ytsearch{count}:{query}", download=False)
|
||||||
|
if not info:
|
||||||
|
return []
|
||||||
|
return [
|
||||||
|
_encode(e["title"], e["id"])
|
||||||
|
for e in (info.get("entries") or [])
|
||||||
|
if e.get("id") and e.get("title")
|
||||||
|
]
|
||||||
|
except Exception as exc:
|
||||||
|
log_error(f"[YouTube] yt-dlp Suche Fehler: {exc}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def _fetch_search_videos(url: str) -> List[str]:
|
||||||
|
"""Holt Videos von einer YouTube-Suche via ytInitialData."""
|
||||||
|
session = _get_session()
|
||||||
|
if session is None:
|
||||||
|
return []
|
||||||
|
try:
|
||||||
|
resp = session.get(url, timeout=DEFAULT_TIMEOUT)
|
||||||
|
resp.raise_for_status()
|
||||||
|
data = _extract_yt_initial_data(resp.text)
|
||||||
|
if not data:
|
||||||
|
return []
|
||||||
|
return _videos_from_search_data(data)
|
||||||
|
except Exception as exc:
|
||||||
|
log_error(f"[YouTube] _fetch_search_videos ({url}): {exc}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_with_ytdlp(video_id: str) -> Optional[str]:
|
||||||
|
"""Loest Video-ID via yt-dlp zu direkter Stream-URL auf."""
|
||||||
|
try:
|
||||||
|
from yt_dlp import YoutubeDL # type: ignore
|
||||||
|
except ImportError:
|
||||||
|
log_error("[YouTube] yt-dlp nicht verfuegbar (script.module.yt-dlp fehlt)")
|
||||||
|
try:
|
||||||
|
import xbmcgui
|
||||||
|
xbmcgui.Dialog().notification(
|
||||||
|
"yt-dlp fehlt",
|
||||||
|
"Bitte yt-dlp in den ViewIT-Einstellungen installieren.",
|
||||||
|
xbmcgui.NOTIFICATION_ERROR,
|
||||||
|
5000,
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
url = f"https://www.youtube.com/watch?v={video_id}"
|
||||||
|
ydl_opts: Dict[str, Any] = {
|
||||||
|
"format": "best[ext=mp4]/best",
|
||||||
|
"quiet": True,
|
||||||
|
"no_warnings": True,
|
||||||
|
"extract_flat": False,
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
with YoutubeDL(ydl_opts) as ydl:
|
||||||
|
info = ydl.extract_info(url, download=False)
|
||||||
|
if not info:
|
||||||
|
return None
|
||||||
|
# Einzelnes Video
|
||||||
|
direct = info.get("url")
|
||||||
|
if direct:
|
||||||
|
return direct
|
||||||
|
# Formatauswahl
|
||||||
|
formats = info.get("formats", [])
|
||||||
|
if formats:
|
||||||
|
return formats[-1].get("url")
|
||||||
|
except Exception as exc:
|
||||||
|
log_error(f"[YouTube] yt-dlp Fehler fuer {video_id}: {exc}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Plugin
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class YoutubePlugin(BasisPlugin):
|
||||||
|
name = "YouTube"
|
||||||
|
|
||||||
|
# Pseudo-Staffeln: nur Suche – Browse-Endpunkte erfordern Login
|
||||||
|
_SEASONS = ["Suche"]
|
||||||
|
|
||||||
|
def capabilities(self) -> Set[str]:
|
||||||
|
return set()
|
||||||
|
|
||||||
|
async def search_titles(
|
||||||
|
self,
|
||||||
|
query: str,
|
||||||
|
progress_callback: ProgressCallback = None,
|
||||||
|
) -> List[str]:
|
||||||
|
if not query.strip():
|
||||||
|
return []
|
||||||
|
# Primär: yt-dlp (robust, kein HTML-Scraping)
|
||||||
|
results = _search_with_ytdlp(query)
|
||||||
|
if results:
|
||||||
|
return results
|
||||||
|
# Fallback: HTML-Scraping
|
||||||
|
if requests is None:
|
||||||
|
return []
|
||||||
|
url = f"{BASE_URL}/results?search_query={requests.utils.quote(query)}" # type: ignore
|
||||||
|
return _fetch_search_videos(url)
|
||||||
|
|
||||||
|
def seasons_for(self, title: str) -> List[str]:
|
||||||
|
return list(self._SEASONS)
|
||||||
|
|
||||||
|
def episodes_for(self, title: str, season: str) -> List[str]:
|
||||||
|
if season == "Suche":
|
||||||
|
# Titel ist bereits ein kodierter Eintrag aus der Suche
|
||||||
|
return [title]
|
||||||
|
return []
|
||||||
|
|
||||||
|
def stream_link_for(self, title: str, season: str, episode: str) -> Optional[str]:
|
||||||
|
video_id = _decode_id(episode) or _decode_id(title)
|
||||||
|
if not video_id:
|
||||||
|
return None
|
||||||
|
return _resolve_with_ytdlp(video_id)
|
||||||
|
|
||||||
|
def resolve_stream_link(self, link: str) -> Optional[str]:
|
||||||
|
return link # bereits direkte URL
|
||||||
|
|
||||||
|
def metadata_for(self, title: str):
|
||||||
|
"""Thumbnail aus Video-ID ableiten."""
|
||||||
|
video_id = _decode_id(title)
|
||||||
|
clean_title = _decode_title(title)
|
||||||
|
info: Dict[str, str] = {"title": clean_title}
|
||||||
|
art: Dict[str, str] = {}
|
||||||
|
if video_id:
|
||||||
|
art["thumb"] = f"https://i.ytimg.com/vi/{video_id}/hqdefault.jpg"
|
||||||
|
art["poster"] = f"https://i.ytimg.com/vi/{video_id}/maxresdefault.jpg"
|
||||||
|
return info, art, None
|
||||||
|
|
||||||
|
|
||||||
|
Plugin = YoutubePlugin
|
||||||
@@ -29,7 +29,8 @@
|
|||||||
</category>
|
</category>
|
||||||
|
|
||||||
<category label="TMDB Erweitert">
|
<category label="TMDB Erweitert">
|
||||||
<setting id="tmdb_api_key" type="text" label="TMDB API Key" default="" />
|
<setting id="tmdb_api_key" type="text" label="TMDB API Key (optional)" default="" />
|
||||||
|
<setting id="tmdb_api_key_active" type="text" label="Aktiver TMDB API Key" default="" />
|
||||||
<setting id="tmdb_prefetch_concurrency" type="number" label="TMDB: gleichzeitige Anfragen (1-20)" default="6" />
|
<setting id="tmdb_prefetch_concurrency" type="number" label="TMDB: gleichzeitige Anfragen (1-20)" default="6" />
|
||||||
<setting id="tmdb_show_cast" type="bool" label="TMDB Besetzung anzeigen" default="false" />
|
<setting id="tmdb_show_cast" type="bool" label="TMDB Besetzung anzeigen" default="false" />
|
||||||
<setting id="tmdb_show_episode_cast" type="bool" label="TMDB Besetzung pro Episode anzeigen" default="false" />
|
<setting id="tmdb_show_episode_cast" type="bool" label="TMDB Besetzung pro Episode anzeigen" default="false" />
|
||||||
@@ -38,6 +39,17 @@
|
|||||||
<setting id="tmdb_log_responses" type="bool" label="TMDB API-Antworten loggen" default="false" />
|
<setting id="tmdb_log_responses" type="bool" label="TMDB API-Antworten loggen" default="false" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
<category label="Anzeige">
|
||||||
|
<setting id="filmpalast_max_page_items" type="number" label="Filmpalast: Max. Eintraege pro Seite" default="15" />
|
||||||
|
<setting id="topstreamfilm_max_page_items" type="number" label="TopStream: Max. Eintraege pro Seite" default="15" />
|
||||||
|
<setting id="aniworld_max_page_items" type="number" label="AniWorld: Max. Eintraege pro Seite" default="15" />
|
||||||
|
<setting id="netzkkino_max_page_items" type="number" label="Netzkino: Max. Eintraege pro Seite" default="15" />
|
||||||
|
<setting id="kkiste_max_page_items" type="number" label="KKiste: Max. Eintraege pro Seite" default="15" />
|
||||||
|
<setting id="hdfilme_max_page_items" type="number" label="HDFilme: Max. Eintraege pro Seite" default="15" />
|
||||||
|
<setting id="moflix_max_page_items" type="number" label="Moflix: Max. Eintraege pro Seite" default="15" />
|
||||||
|
<setting id="einschalten_max_page_items" type="number" label="Einschalten: Max. Eintraege pro Seite" default="15" />
|
||||||
|
</category>
|
||||||
|
|
||||||
<category label="Wiedergabe">
|
<category label="Wiedergabe">
|
||||||
<setting id="autoplay_enabled" type="bool" label="Autoplay (bevorzugten Hoster automatisch waehlen)" default="false" />
|
<setting id="autoplay_enabled" type="bool" label="Autoplay (bevorzugten Hoster automatisch waehlen)" default="false" />
|
||||||
<setting id="preferred_hoster" type="text" label="Bevorzugter Hoster" default="voe" />
|
<setting id="preferred_hoster" type="text" label="Bevorzugter Hoster" default="voe" />
|
||||||
@@ -111,4 +123,9 @@
|
|||||||
<setting id="show_url_info_filmpalast" type="bool" label="Filmpalast: Aktuelle URL anzeigen" default="false" />
|
<setting id="show_url_info_filmpalast" type="bool" label="Filmpalast: Aktuelle URL anzeigen" default="false" />
|
||||||
<setting id="log_errors_filmpalast" type="bool" label="Filmpalast: Fehler mitschreiben" default="false" />
|
<setting id="log_errors_filmpalast" type="bool" label="Filmpalast: Fehler mitschreiben" default="false" />
|
||||||
</category>
|
</category>
|
||||||
|
<category label="YouTube">
|
||||||
|
<setting id="install_ytdlp" type="action" label="yt-dlp installieren/reparieren" action="RunPlugin(plugin://plugin.video.viewit/?action=install_ytdlp)" option="close" />
|
||||||
|
<setting id="ytdlp_status" type="text" label="yt-dlp Status" default="-" enable="false" />
|
||||||
|
</category>
|
||||||
|
|
||||||
</settings>
|
</settings>
|
||||||
|
|||||||
@@ -15,19 +15,3 @@ msg=$(cat "$1")
|
|||||||
updated_msg=$(echo "$msg" | sed -E "s/bump to [0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?[^ ]*/bump to ${version}/g")
|
updated_msg=$(echo "$msg" | sed -E "s/bump to [0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?[^ ]*/bump to ${version}/g")
|
||||||
echo "$updated_msg" > "$1"
|
echo "$updated_msg" > "$1"
|
||||||
|
|
||||||
today=$(date +%Y-%m-%d)
|
|
||||||
|
|
||||||
# Changelog-Eintrag aufbauen
|
|
||||||
{
|
|
||||||
echo "## ${version} - ${today}"
|
|
||||||
echo ""
|
|
||||||
while IFS= read -r line; do
|
|
||||||
[[ -z "$line" ]] && continue
|
|
||||||
echo "- ${line}"
|
|
||||||
done <<< "$updated_msg"
|
|
||||||
echo ""
|
|
||||||
cat CHANGELOG-DEV.md
|
|
||||||
} > /tmp/changelog_new.md
|
|
||||||
|
|
||||||
mv /tmp/changelog_new.md CHANGELOG-DEV.md
|
|
||||||
git add CHANGELOG-DEV.md
|
|
||||||
|
|||||||
43
scripts/hooks/prepare-commit-msg
Executable file
43
scripts/hooks/prepare-commit-msg
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# prepare-commit-msg: Changelog-Eintrag in CHANGELOG-DEV.md schreiben (nur dev-Branch)
|
||||||
|
# Laeuft nach pre-commit (Version bereits gebumpt) und vor commit-msg.
|
||||||
|
# git add funktioniert hier zuverlässig für den aktuellen Commit.
|
||||||
|
|
||||||
|
branch=$(git symbolic-ref --short HEAD 2>/dev/null)
|
||||||
|
[[ "$branch" != "dev" ]] && exit 0
|
||||||
|
|
||||||
|
root=$(git rev-parse --show-toplevel)
|
||||||
|
cd "$root"
|
||||||
|
|
||||||
|
# Nur bei normalem Commit (nicht amend, merge, squash)
|
||||||
|
commit_type="${2:-}"
|
||||||
|
[[ "$commit_type" == "merge" || "$commit_type" == "squash" ]] && exit 0
|
||||||
|
|
||||||
|
# Aktuelle Version aus addon.xml (bereits vom pre-commit Hook hochgezaehlt)
|
||||||
|
version=$(grep -oP 'version="\K[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?[^"]*' addon/addon.xml | head -1)
|
||||||
|
[[ -z "$version" ]] && exit 0
|
||||||
|
|
||||||
|
# Commit-Message aus der Datei lesen (bereits vom User eingegeben oder per -m übergeben)
|
||||||
|
msg=$(cat "$1")
|
||||||
|
# Kommentarzeilen entfernen
|
||||||
|
msg=$(echo "$msg" | grep -v '^#' | sed '/^[[:space:]]*$/d' | head -1)
|
||||||
|
[[ -z "$msg" ]] && exit 0
|
||||||
|
|
||||||
|
today=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
# Prüfen ob dieser Versions-Eintrag bereits existiert (Doppel-Eintrag verhindern)
|
||||||
|
if grep -q "^## ${version} " CHANGELOG-DEV.md 2>/dev/null; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Changelog-Eintrag aufbauen und prependen
|
||||||
|
{
|
||||||
|
echo "## ${version} - ${today}"
|
||||||
|
echo ""
|
||||||
|
echo "- ${msg}"
|
||||||
|
echo ""
|
||||||
|
cat CHANGELOG-DEV.md
|
||||||
|
} > /tmp/changelog_new.md
|
||||||
|
|
||||||
|
mv /tmp/changelog_new.md CHANGELOG-DEV.md
|
||||||
|
git add CHANGELOG-DEV.md
|
||||||
Reference in New Issue
Block a user