YouTube_captions_search_engine/scripts/findTreatedChannelWithMostSubscribers.py

24 lines
825 B
Python
Raw Normal View History

#!/usr/bin/python3
import os, requests, json
channelIds = [channelId.replace('.zip', '') for channelId in next(os.walk('channels/'))[2]]
maxResults = 50
channelIdsChunks = [channelIds[i : i + maxResults] for i in range(0, len(channelIds), maxResults)]
mostSubscriberCount = 0
mostSubscriberChannel = None
for channelIds in channelIdsChunks:
url = 'https://yt.lemnoslife.com/noKey/channels?part=statistics&id=' + ','.join(channelIds)
content = requests.get(url).text
data = json.loads(content)
items = data['items']
for item in items:
subscriberCount = int(item['statistics']['subscriberCount'])
if mostSubscriberCount < subscriberCount:
mostSubscriberCount = subscriberCount
mostSubscriberChannel = item['id']
print(mostSubscriberChannel, mostSubscriberCount)