add a video_filter parameter to be able to browse only local
- when browsing ( and not searching ) it is possible to select filter=local that will show only local video - create dedicated method to build kodi and peertube api url - bumped version to 0.3.1.1 to indicate this change - if selected upstream might want to change it to 0.3.2
This commit is contained in:
parent
f1307e142e
commit
913e5fb905
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.peertube" name="PeerTube" version="0.3.1" provider-name="Cyrille Bollu">
|
<addon id="plugin.video.peertube" name="PeerTube" version="0.3.1.1" provider-name="Cyrille Bollu">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.25.0"/>
|
<import addon="xbmc.python" version="2.25.0"/>
|
||||||
<import addon="script.module.addon.signals" version="0.0.3"/>
|
<import addon="script.module.addon.signals" version="0.0.3"/>
|
||||||
|
@ -20,6 +20,8 @@
|
||||||
<email>cyrille.bollu2@gmail.com</email>
|
<email>cyrille.bollu2@gmail.com</email>
|
||||||
<source>https://github.com/StCyr/plugin.video.peertube</source>
|
<source>https://github.com/StCyr/plugin.video.peertube</source>
|
||||||
<news>
|
<news>
|
||||||
|
0.3.1.1
|
||||||
|
Add local videos only browsing
|
||||||
0.3.1
|
0.3.1
|
||||||
Fixed some bugs
|
Fixed some bugs
|
||||||
The 'change current instance" functionality currently doesn't work because
|
The 'change current instance" functionality currently doesn't work because
|
||||||
|
|
48
peertube.py
48
peertube.py
|
@ -50,6 +50,10 @@ class PeertubeAddon():
|
||||||
self.play = 0
|
self.play = 0
|
||||||
self.torrent_name = ''
|
self.torrent_name = ''
|
||||||
|
|
||||||
|
# filter= 'local' or 'all-local' in verb search rest api
|
||||||
|
# applied for browsing only
|
||||||
|
self.video_filter = addon.getSetting('video_filter')
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def query_peertube(self, req):
|
def query_peertube(self, req):
|
||||||
|
@ -148,7 +152,7 @@ class PeertubeAddon():
|
||||||
torrent_url = backup_url
|
torrent_url = backup_url
|
||||||
|
|
||||||
# Compose the correct URL for Kodi
|
# Compose the correct URL for Kodi
|
||||||
url = '{0}?action=play_video&url={1}'.format(self.plugin_url, torrent_url)
|
url = self.build_kodi_url_action_url('play_video', torrent_url)
|
||||||
|
|
||||||
elif data_type == 'instances':
|
elif data_type == 'instances':
|
||||||
# TODO: Add a context menu to select instance as preferred instance
|
# TODO: Add a context menu to select instance as preferred instance
|
||||||
|
@ -156,7 +160,7 @@ class PeertubeAddon():
|
||||||
list_item.setProperty('IsPlayable', 'false')
|
list_item.setProperty('IsPlayable', 'false')
|
||||||
|
|
||||||
# Set URL to select this instance
|
# Set URL to select this instance
|
||||||
url = '{0}?action=select_instance&url={1}'.format(self.plugin_url, data['host'])
|
url = self.build_kodi_url_action_url('select_instance',data['host'])
|
||||||
|
|
||||||
# Add our item to the listing as a 3-element tuple.
|
# Add our item to the listing as a 3-element tuple.
|
||||||
listing.append((url, list_item, False))
|
listing.append((url, list_item, False))
|
||||||
|
@ -170,6 +174,17 @@ class PeertubeAddon():
|
||||||
|
|
||||||
return listing
|
return listing
|
||||||
|
|
||||||
|
def build_peertube_rest_api_search_request(self,search,start):
|
||||||
|
# Didn't yet find a correct way to do a search with a filter set to local.
|
||||||
|
# then if a search value is given it won't filter on local
|
||||||
|
if search is None:
|
||||||
|
# video api does not provide search=
|
||||||
|
req = '{0}/api/v1/videos?count={1}&start={2}&sort={3}&filter={4}'.format(self.selected_inst, self.items_per_page, start, self.sort_method,self.video_filter)
|
||||||
|
else:
|
||||||
|
# search api does not provide filter=
|
||||||
|
req = '{0}/api/v1/search/videos?count={1}&start={2}&sort={3}&search={4}'.format(self.selected_inst, self.items_per_page, start, self.sort_method,search)
|
||||||
|
return req
|
||||||
|
|
||||||
def search_videos(self, start):
|
def search_videos(self, start):
|
||||||
"""
|
"""
|
||||||
Function to search for videos on a PeerTube instance and navigate in the results
|
Function to search for videos on a PeerTube instance and navigate in the results
|
||||||
|
@ -185,7 +200,7 @@ class PeertubeAddon():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Create the PeerTube REST API request for searching videos
|
# Create the PeerTube REST API request for searching videos
|
||||||
req = '{0}/api/v1/search/videos?search={1}&count={2}&start={3}&sort={4}'.format(self.selected_inst, search, self.items_per_page, start, self.sort_method)
|
req = self.build_peertube_rest_api_search_request(search,start)
|
||||||
|
|
||||||
# Send the query
|
# Send the query
|
||||||
results = self.query_peertube(req)
|
results = self.query_peertube(req)
|
||||||
|
@ -212,7 +227,7 @@ class PeertubeAddon():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Create the PeerTube REST API request for listing videos
|
# Create the PeerTube REST API request for listing videos
|
||||||
req = '{0}/api/v1/videos?count={1}&start={2}&sort={3}'.format(self.selected_inst, self.items_per_page, start, self.sort_method)
|
req = self.build_peertube_rest_api_search_request(None,start)
|
||||||
|
|
||||||
# Send the query
|
# Send the query
|
||||||
results = self.query_peertube(req)
|
results = self.query_peertube(req)
|
||||||
|
@ -309,6 +324,14 @@ class PeertubeAddon():
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def build_kodi_url_action_url(self,action,url):
|
||||||
|
url = '{0}?action={1}&url={2}'.format(self.plugin_url,action,url)
|
||||||
|
return url
|
||||||
|
|
||||||
|
def build_kodi_url_action(self,action):
|
||||||
|
url = '{0}?action={1}&start=0'.format(self.plugin_url,action)
|
||||||
|
return url
|
||||||
|
|
||||||
def main_menu(self):
|
def main_menu(self):
|
||||||
"""
|
"""
|
||||||
Addon's main menu
|
Addon's main menu
|
||||||
|
@ -321,17 +344,17 @@ class PeertubeAddon():
|
||||||
|
|
||||||
# 1st menu entry
|
# 1st menu entry
|
||||||
list_item = xbmcgui.ListItem(label='Browse selected instance')
|
list_item = xbmcgui.ListItem(label='Browse selected instance')
|
||||||
url = '{0}?action=browse_videos&start=0'.format(self.plugin_url)
|
url = self.build_kodi_url_action('browse_videos')
|
||||||
listing.append((url, list_item, True))
|
listing.append((url, list_item, True))
|
||||||
|
|
||||||
# 2nd menu entry
|
# 2nd menu entry
|
||||||
list_item = xbmcgui.ListItem(label='Search on selected instance')
|
list_item = xbmcgui.ListItem(label='Search on selected instance')
|
||||||
url = '{0}?action=search_videos&start=0'.format(self.plugin_url)
|
url = self.build_kodi_url_action('search_videos')
|
||||||
listing.append((url, list_item, True))
|
listing.append((url, list_item, True))
|
||||||
|
|
||||||
# 3rd menu entry
|
# 3rd menu entry
|
||||||
list_item = xbmcgui.ListItem(label='Select other instance')
|
list_item = xbmcgui.ListItem(label='Select other instance')
|
||||||
url = '{0}?action=browse_instances&start=0'.format(self.plugin_url)
|
url = self.build_kodi_url_action('browse_instances')
|
||||||
listing.append((url, list_item, True))
|
listing.append((url, list_item, True))
|
||||||
|
|
||||||
# Add our listing to Kodi.
|
# Add our listing to Kodi.
|
||||||
|
@ -356,19 +379,20 @@ class PeertubeAddon():
|
||||||
|
|
||||||
# Check the parameters passed to the plugin
|
# Check the parameters passed to the plugin
|
||||||
if params:
|
if params:
|
||||||
if params['action'] == 'browse_videos':
|
action = params['action']
|
||||||
|
if action == 'browse_videos':
|
||||||
# Browse videos on selected instance
|
# Browse videos on selected instance
|
||||||
self.browse_videos(params['start'])
|
self.browse_videos(params['start'])
|
||||||
elif params['action'] == 'search_videos':
|
elif action == 'search_videos':
|
||||||
# Search for videos on selected instance
|
# Search for videos on selected instance
|
||||||
self.search_videos(params['start'])
|
self.search_videos(params['start'])
|
||||||
elif params['action'] == 'browse_instances':
|
elif action == 'browse_instances':
|
||||||
# Browse peerTube instances
|
# Browse peerTube instances
|
||||||
self.browse_instances(params['start'])
|
self.browse_instances(params['start'])
|
||||||
elif params['action'] == 'play_video':
|
elif action == 'play_video':
|
||||||
# Play video from provided URL.
|
# Play video from provided URL.
|
||||||
self.play_video(params['url'])
|
self.play_video(params['url'])
|
||||||
elif params['action'] == 'select_instance':
|
elif action == 'select_instance':
|
||||||
self.select_instance(params['url'])
|
self.select_instance(params['url'])
|
||||||
else:
|
else:
|
||||||
# Display the addon's main menu when the plugin is called from Kodi UI without any parameters
|
# Display the addon's main menu when the plugin is called from Kodi UI without any parameters
|
||||||
|
|
|
@ -37,3 +37,7 @@ msgstr ""
|
||||||
msgctxt "#30004"
|
msgctxt "#30004"
|
||||||
msgid "Delete downloaded videos when Kodi exits"
|
msgid "Delete downloaded videos when Kodi exits"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30005"
|
||||||
|
msgid "Filter local or all videos ( for browsing only )"
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -7,4 +7,5 @@
|
||||||
<setting id="preferred_resolution" type="select" values="1080|720|480|360|240" default='480' label="30003"/>
|
<setting id="preferred_resolution" type="select" values="1080|720|480|360|240" default='480' label="30003"/>
|
||||||
<setting type="sep"/>
|
<setting type="sep"/>
|
||||||
<setting id="delete_files" type="bool" default="true" label="30004"/>
|
<setting id="delete_files" type="bool" default="true" label="30004"/>
|
||||||
|
<setting id="video_filter" type="select" values="local|all-local" default="all-local" label="30005"/>
|
||||||
</settings>
|
</settings>
|
||||||
|
|
Loading…
Reference in New Issue