Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin.video.invidious] 0.2.8+nexus.0 #4442

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.video.invidious/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.invidious"
name="Invidious"
version="0.2.7+nexus.0"
version="0.2.8+nexus.0"
provider-name="petterreinholdtsen">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand Down
21 changes: 4 additions & 17 deletions plugin.video.invidious/resources/lib/invidious_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,13 @@ def make_get_request(self, *path, **params):

if response.status_code > 300:
xbmc.log(f'invidious API request {assembled_url} with {params} failed with HTTP status {response.status_code}: {response.reason}.', xbmc.LOGWARNING)
dialog = xbmcgui.Dialog()
msg = self.addon.getLocalizedString(30014).format(
request_url=assembled_url,
request_params=params,
status_code=response.status_code,
status_reason=response.reason,
)
dialog.notification(
self.addon.getLocalizedString(30011),
msg,
"error"
)
return None

return response

def parse_response(self, response):
if not response:
return
return None
data = response.json()

# If a channel or playlist is opened, the videos are packaged
Expand Down Expand Up @@ -165,10 +153,9 @@ def search(self, *terms):

def fetch_video_information(self, video_id):
response = self.make_get_request("videos/", video_id)

data = response.json()

return data
if not response:
return None
return response.json()

def fetch_channel_list(self, channel_id):
response = self.make_get_request(f"channels/videos/{channel_id}")
Expand Down
11 changes: 9 additions & 2 deletions plugin.video.invidious/resources/lib/invidious_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,17 @@ def instance_autodetect(self):
if 'https' == instance['type']:
instance_url = instance['uri']
# Make sure the instance work for us. This test avoid
# those rejecting us with HTTP status 429.
# those rejecting us with HTTP status 429. Some
# instances return a sensible value for the special
# lists but not for an individual video, so test with
# a fairly randomly picked video id to avoid partly
# working instances.
test_video_id = '1l2_uCyBXQ0'
api_client = invidious_api.InvidiousAPIClient(instance_url)
if api_client.fetch_special_list(self.SPECIAL_LISTS[0]):
if api_client.fetch_video_information(test_video_id):
return instance_url
else:
xbmc.log(f'rejecting non-working instance {instanceinfo}', xbmc.LOGDEBUG)

xbmc.log('invidious no working https type instance returned from api.invidious.io.', xbmc.LOGWARNING)
# FIXME figure out how to show failing autodetection to the user.
Expand Down
Loading