Skip to content

Commit

Permalink
Finish implementing music videos support
Browse files Browse the repository at this point in the history
  • Loading branch information
romanvm committed Dec 2, 2023
1 parent f234024 commit ec7c7d9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
32 changes: 24 additions & 8 deletions plugin.video.external.library/libs/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
SeasonsHandler,
EpisodesHandler,
RecentEpisodesHandler,
MusicVideosHandler,
RecentMusicVideosHandler,
)
from libs.exceptions import NoDataError, RemoteKodiError
from libs.kodi_service import ADDON, ADDON_ID, GettextEmulator, get_plugin_url
Expand All @@ -49,6 +51,8 @@
'seasons': SeasonsHandler,
'episodes': EpisodesHandler,
'recent_episodes': RecentEpisodesHandler,
'music_videos': MusicVideosHandler,
'recent_music_videos': RecentMusicVideosHandler,
}


Expand Down Expand Up @@ -79,6 +83,18 @@ def root():
'thumb': 'DefaultRecentlyAddedEpisodes.png'})
url = get_plugin_url(content_type='recent_episodes')
xbmcplugin.addDirectoryItem(HANDLE, url, list_item, isFolder=True)
if ADDON.getSettingBool('show_music_videos'):
list_item = ListItem(f'[{_("Music videos")}]')
list_item.setArt({'icon': 'DefaultMusicVideos.png', 'thumb': 'DefaultMusicVideos.png'})
url = get_plugin_url(content_type='music_videos')
xbmcplugin.addDirectoryItem(HANDLE, url, list_item, isFolder=True)
if ADDON.getSettingBool('show_recent_music_videos'):
list_item = ListItem(f'[{_("Recently added music video")}]')
list_item.setArt({'icon': 'DefaultRecentlyAddedMusicVideos.png',
'thumb': 'DefaultRecentlyAddedMusicVideos.png'})
url = get_plugin_url(content_type='recent_music_videos')
xbmcplugin.addDirectoryItem(HANDLE, url, list_item, isFolder=True)
xbmcplugin.endOfDirectory(HANDLE)


def show_media_items(content_type, tvshowid=None, season=None, parent_category=None):
Expand Down Expand Up @@ -128,18 +144,18 @@ def show_media_items(content_type, tvshowid=None, season=None, parent_category=N
for sort_method in content_type_handler.get_sort_methods():
xbmcplugin.addSortMethod(HANDLE, sort_method)
logger.debug('Finished creating a list of %s items.', content_type)
xbmcplugin.endOfDirectory(HANDLE)


def router(paramstring):
params = dict(parse_qsl(paramstring))
logger.debug('Called addon with params: %s', str(sys.argv))
if 'content_type' not in params:
root()
else:
if (tvshowid := params.get('tvshowid')) is not None:
tvshowid = int(tvshowid)
if (season := params.get('season')) is not None:
season = int(season)
parent_category = params.get('parent_category')
show_media_items(params['content_type'], tvshowid, season, parent_category)
xbmcplugin.endOfDirectory(HANDLE)
return
if (tvshowid := params.get('tvshowid')) is not None:
tvshowid = int(tvshowid)
if (season := params.get('season')) is not None:
season = int(season)
parent_category = params.get('parent_category')
show_media_items(params['content_type'], tvshowid, season, parent_category)
3 changes: 3 additions & 0 deletions plugin.video.external.library/libs/media_info_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ def get_method_args(self) -> Iterable[Any]:
('productioncode', 'setProductionCode', SimpleMediaPropertySetter),
('specialsortseason', 'setSortSeason', NonNegativeValueSetter),
('specialsortepisode', 'setSortEpisode', NonNegativeValueSetter),
('album', 'setAlbum', SimpleMediaPropertySetter),
('artist', 'setArtists', SimpleMediaPropertySetter),
('track', 'setTrack', NonNegativeValueSetter),
]


Expand Down
13 changes: 13 additions & 0 deletions plugin.video.external.library/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@
<dependency type="visible" setting="show_tvshows">true</dependency>
</dependencies>
</setting>
<setting id="show_music_videos" type="boolean" label="32027" help="">
<level>0</level>
<default>true</default>
<control type="toggle"/>
</setting>
<setting id="show_recent_music_videos" type="boolean" label="32028" help="">
<level>0</level>
<default>true</default>
<control type="toggle"/>
<dependencies>
<dependency type="visible" setting="show_music_videos">true</dependency>
</dependencies>
</setting>
</group>
</category>
<category id="playback" label="32022" help="">
Expand Down

0 comments on commit ec7c7d9

Please sign in to comment.