Simplify scripts/findTreatedChannelWithMostSubscribers.py

This commit is contained in:
Benjamin Loison 2023-07-28 11:40:07 +02:00
parent 654769b80b
commit b60bb22112
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os, requests, json import os, requests
channelIds = [channelId.replace('.zip', '') for channelId in next(os.walk('channels/'))[2]] channelIds = [channelId.replace('.zip', '') for channelId in next(os.walk('channels/'))[2]]
maxResults = 50 maxResults = 50
@ -11,8 +11,7 @@ mostSubscriberChannel = None
for channelIds in channelIdsChunks: for channelIds in channelIdsChunks:
url = 'https://yt.lemnoslife.com/noKey/channels?part=statistics&id=' + ','.join(channelIds) url = 'https://yt.lemnoslife.com/noKey/channels?part=statistics&id=' + ','.join(channelIds)
content = requests.get(url).text data = requests.get(url).json()
data = json.loads(content)
items = data['items'] items = data['items']
for item in items: for item in items:
subscriberCount = int(item['statistics']['subscriberCount']) subscriberCount = int(item['statistics']['subscriberCount'])