Invidious calls cleanup, add fields, fix subscriptions

This commit is contained in:
Brahim Hadriche committed 2022-12-01 16:50:06 -05:00
1 parent 58d2fc7041
commit 2d1490f925
3 files changed
+22 -82

No files matched your search

+18 -1
View File
@@ -18,6 +18,11 @@
"required": false, "required": false,
"type": "#ISO3166", "type": "#ISO3166",
"default": "GetUserCountryCode" "default": "GetUserCountryCode"
},
"fields": {
"required": false,
"type": "string",
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow"
} }
} }
}, },
@@ -25,7 +30,14 @@
"name": "popular", "name": "popular",
"displayName": "Popular", "displayName": "Popular",
"url": "/api/v1/popular", "url": "/api/v1/popular",
"authenticated": false "authenticated": false,
"queryParams": {
"fields": {
"required": false,
"type": "string",
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow"
}
}
}, },
{ {
"name": "search", "name": "search",
@@ -90,6 +102,11 @@
"required": false, "required": false,
"type": "#ISO3166", "type": "#ISO3166",
"default": "GetUserCountryCode" "default": "GetUserCountryCode"
},
"fields": {
"required": false,
"type": "string",
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow"
} }
} }
}, },
-80
View File
@@ -31,36 +31,6 @@ namespace Invidious
} }
end function end function
function GetPopular() as object
instance = InvidiousSettings.GetSelectedInstance()
url = `${instance}${Invidious.POPULAR_ENDPOINT}`
args = Invidious.DefaultArgs()
response = Requests().get(url, args)
if response.statuscode = 200
return response.json
end if
return invalid
end function
function GetTrending(trendingType = "" as string) as object
instance = InvidiousSettings.GetSelectedInstance()
url = `${instance}${Invidious.TRENDING_ENDPOINT}`
args = Invidious.DefaultArgs()
if trendingType <> ""
args.params.type = trendingType
end if
response = Requests().get(url, args)
if response.statuscode = 200
return response.json
end if
return invalid
end function
function GetVideoUrl(videoId as string, itag as string, local as boolean) as string function GetVideoUrl(videoId as string, itag as string, local as boolean) as string
instance = InvidiousSettings.GetSelectedInstance() instance = InvidiousSettings.GetSelectedInstance()
url = `${instance}/latest_version?id=${videoId}&itag=${itag}` url = `${instance}/latest_version?id=${videoId}&itag=${itag}`
@@ -152,56 +122,6 @@ namespace Invidious
} }
end function end function
function GetUserFeed() as object
authToken = InvidiousSettings.GetAuthToken()
if authToken = invalid
return false
end if
headers = Invidious.GetAuthenticationHeaders(authToken.token)
url = `${authToken.instance}${Invidious.AUTH_FEED}`
args = {
headers: headers,
retryCount: 3 'Sometimes authentication fails randomly with a valid token...
}
response = Requests().get(url, args)
if response.statuscode = 403
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
end if
if response.statuscode = 200
return response.json.videos
end if
return invalid
end function
function GetUserPlaylists() as object
authToken = InvidiousSettings.GetAuthToken()
if authToken = invalid
return false
end if
headers = Invidious.GetAuthenticationHeaders(authToken.token)
url = `${authToken.instance}${Invidious.AUTH_PLAYLISTS}`
args = {
headers: headers,
retryCount: 3 'Sometimes authentication fails randomly with a valid token...
}
response = Requests().get(url, args)
if response.statuscode = 403
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
end if
if response.statuscode = 200
return response.json
end if
return invalid
end function
function Logout() as boolean function Logout() as boolean
authToken = InvidiousSettings.GetAuthToken() authToken = InvidiousSettings.GetAuthToken()
if authToken = invalid if authToken = invalid
+4 -1
View File
@@ -92,7 +92,10 @@ class InvidiousService
m.DeleteExpiredToken(response) m.DeleteExpiredToken(response)
if response.statuscode = 200 if response.statuscode = 200
return response.json.videos videos = []
videos.Append(response.json.notifications)
videos.Append(response.json.videos)
return videos
end if end if
return invalid return invalid
end function end function