Skip to content

Commit d2ad869

Browse files
authored
Fix assign torrent for themoviedb.helper (#35)
* Fix assign torrent for themoviedb.helper * Fix "assign torrent" only for new tmdb helper version * Better fix for "torrent assign" for tmdb helper items. * Improve approach with 'tvshow.tmdb' field (for torrent assignment).
1 parent 580999d commit d2ad869

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

context_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"ListItem.Mediatype",
1616
"ListItem.TMDB",
1717
"ListItem.UniqueID(tmdb)",
18+
"ListItem.UniqueID(tvshow.tmdb)",
1819
"ListItem.UniqueID(Elementum)",
1920
"ListItem.Property(ShowTMDBId)",
2021
"ListItem.Label",

plugin.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,63 @@ def doAssign():
5151

5252
if tmdbID == "":
5353
if path.startswith("plugin://plugin.video.elementum"):
54+
log.debug("Using approach for old version of plugin.video.elementum")
5455
use_elementum_path = True
5556
tmdbID = getTMDBidFromElementumPath(path)
5657
if not tmdbID:
58+
log.error("Could not get tmdbID for %s" % path)
5759
return
5860

5961
if mediatype == 'season':
6062
season_number = getSeasonNumberFromElementumPath(path)
6163
if not season_number:
64+
log.error("Could not get season_number for %s" % path)
6265
return
6366

6467
if mediatype == 'episode':
6568
season_number = getSeasonNumberFromElementumPath(path)
6669
episode_number = getEpisodeNumberFromElementumPath(path)
6770
if not season_number or not episode_number:
71+
log.error("Could not get season_number or episode_number for %s" % path)
6872
return
6973
else:
7074
dbid = getDbId()
7175
if not dbid.isdigit():
7276
log.error("Kodi library ID is wrong %s" % dbid)
7377
xbmcgui.Dialog().notification(ADDON.getLocalizedString(32007), ADDON.getLocalizedString(32016), xbmcgui.NOTIFICATION_WARNING, 3000)
7478
return
79+
else:
80+
# Elementum uses TMDB ID of the season/episode for the season/episode, so we can use it directly.
81+
# But some addons (like new versions of TMDB Helper) use TMDB ID of the show for the season/episode.
82+
# Thus, if they have generic "tvshow.tmdb" field - then we use it in conjunction with season/episode number,
83+
# and then we get specific season's/episode's TMDB ID in golang part (by making extra API call).
84+
try:
85+
tvshow_tmdb = sys.listitem.getUniqueID('tvshow.tmdb') if kodi_version < 20 else sys.listitem.getVideoInfoTag().getUniqueID('tvshow.tmdb')
86+
except AttributeError:
87+
tvshow_tmdb = ""
88+
if tvshow_tmdb:
89+
log.debug("Using approach with 'tvshow.tmdb' field")
90+
use_elementum_path = True
91+
tmdbID = tvshow_tmdb
92+
93+
if mediatype == 'season':
94+
season_number = xbmc.getInfoLabel('ListItem.Season')
95+
if not season_number:
96+
log.error("Could not get season_number for %s" % path)
97+
return
98+
99+
if mediatype == 'episode':
100+
season_number = xbmc.getInfoLabel('ListItem.Season')
101+
episode_number = xbmc.getInfoLabel('ListItem.Episode')
102+
if not season_number or not episode_number:
103+
log.error("Could not get season_number or episode_number for %s" % path)
104+
return
75105

76106
# we also can use plugin://plugin.video.elementum/torrents/
77107
file = xbmcgui.Dialog().browseSingle(1, ADDON.getLocalizedString(32010), 'files', '', False, False, 'plugin://plugin.video.elementum/history/')
78108

79109
if not file or file == 'plugin://plugin.video.elementum/history/':
110+
log.info("User did not select a torrent.")
80111
return
81112

82113
try:

0 commit comments

Comments
 (0)