Skip to content

Commit

Permalink
Merge pull request #725 from anxdpanic/pr
Browse files Browse the repository at this point in the history
add search by channel or playlist id
  • Loading branch information
anxdpanic authored Jan 25, 2020
2 parents a913387 + 0322056 commit 928ee47
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<extension point="xbmc.addon.metadata">
<news>
[add] 'Play (Ask for quality)' context menu
[add] search by channel or playlist id
[add] hide_folders, hide_playlists, hide_search, and hide_live to /channel/&lt;channel_id&gt;/ end-point
- ie. plugin://plugin.video.youtube/channel/UC4PooiX37Pld1T8J5SYT-SQ/?hide_folders=true will hide all folders(Playlists, Search, and Live) in the channel listing
[fix] playback for some videos (ie. music videos)
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
6.5.3
[add] 'Play (Ask for quality)' context menu
[add] search by channel or playlist id
[add] hide_folders, hide_playlists, hide_search, and hide_live to /channel/<channel_id>/ end-point
- ie. plugin://plugin.video.youtube/channel/UC4PooiX37Pld1T8J5SYT-SQ/?hide_folders=true will hide all folders(Playlists, Search, and Live) in the channel listing
[fix] playback for some videos (ie. music videos)
Expand Down
23 changes: 21 additions & 2 deletions resources/lib/youtube_plugin/youtube/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
See LICENSES/GPL-2.0-only for more information.
"""

import os
import json
import os
import re
import shutil
import socket
from base64 import b64decode
Expand Down Expand Up @@ -994,9 +995,27 @@ def endpoint_search(self, context, re_match):

return self.on_search(query, context, re_match)

def on_search(self, search_text, context, re_match):
def _search_channel_or_playlist(self, context, id_string):
json_data = {}
result = []

if re.match(r'U[CU][0-9a-zA-Z_\-]{20,24}', id_string):
json_data = self.get_client(context).get_channels(id_string)

elif re.match(r'[OP]L[0-9a-zA-Z_\-]{30,40}', id_string):
json_data = self.get_client(context).get_playlists(id_string)

if not json_data or not v3.handle_error(self, context, json_data):
return []

result.extend(v3.response_to_items(self, context, json_data))
return result

def on_search(self, search_text, context, re_match):
result = self._search_channel_or_playlist(context, search_text)
if result: # found a channel or playlist matching search_text
return result

channel_id = context.get_param('channel_id', '')
event_type = context.get_param('event_type', '')
hide_folders = str(context.get_param('hide_folders', False)).lower() == 'true'
Expand Down

0 comments on commit 928ee47

Please sign in to comment.