Open krasnoludkolo opened 9 months ago
It seems to be an encoding issue, as discussed on Discord. It was proposed to use urldecode
at https://github.com/Benjamin-Loison/YouTube-operational-API/blob/a1a9a7c3ea738153fc2400ec40ed4a742ef90885/channels.php#L76 but I would prefer a solution at the response sent level than at the parameters receiving level, because it would possibly simplify the response sent and hence correct the parameters received.
While we do not know the standards having a solution working for these 3 cases (while it currently works for the first 2) seems to be appropriate:
nextPageToken
as pageToken
from JSON viewerrequests
explicit URL, i.e. f'https://yt.lemnoslife.com/channels?part=popular&id=UC...&pageToken={items[0]["nextPageToken"]}'
requests
params
, i.e. requests.get('https://yt.lemnoslife.com/channels', params = {'part': 'popular', 'id': 'UC...', 'pageToken': items[0]['nextPageToken']})
Note that this issue may be encountered for all paginations of this API and possibly other parameters, hence being quite sure of what we are doing seems necessary.
https://www.php.net/manual/en/function.urldecode.php
Seems related to #114.
Own testing script:
import requests
channelId = 'UC9r_nQL7uZ3eXQRFwzX7xZQ'
baseUrl = f'http://localhost/YouTube-operational-API/channels' # ?part=popular&id={channelId}
nextPageToken = ''
while True:
params = {
'part': 'popular',
'id': channelId,
}
if nextPageToken:
params['pageToken'] = nextPageToken
url = baseUrl
#url = baseUrl + (f'&pageToken={nextPageToken}' if nextPageToken else '')
#params = None
response = requests.get(url, params = params).json()
item = response['items'][0]
for video in item['popular']:
print(video['title'])
nextPageToken = item.get('nextPageToken')
if not nextPageToken:
break
As we made some progress thanks to today investigation, that I am not very keen with what should be done and that I am a bit in a hurry, I postpone properly solving this issue.
Related to #235
I want to collect all videos from channel which is automatically created by YouTube. I'm using new
popular
part
added tochannels
endpoint.I'm making request
In response I got
which I'm using for next request:
in response I got