Add {removeChannelsBeingTreated, findTreatedChannelWithMost{Comments, Subscribers}}.py

This commit is contained in:
Benjamin Loison 2023-01-04 02:41:07 +01:00
parent 2a33be9272
commit dde52da8c8
3 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#!/usr/bin/python3
infix = ' comments were found for this channel.'
biggestCommentsCount = 0
with open('nohup.out') as f:
lines = f.read().splitlines()
for line in lines:
if infix in line:
#print(line)
commentsCount = int(line.split(': ')[-1].split(infix)[0])
#print(commentsCount)
if biggestCommentsCount < commentsCount:
biggestCommentsCount = commentsCount
print(biggestCommentsCount)

View File

@ -0,0 +1,23 @@
#!/usr/bin/python3
import os, requests, json
channelIds = next(os.walk('channels/'))[1]
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)

View File

@ -0,0 +1,23 @@
#!/usr/bin/python3
import shutil
infix = ': Treating channel '
path = 'channels/'
threads = {}
with open('nohup.out') as f:
lines = f.read().splitlines()
for line in lines:
if infix in line:
#print(line)
threadId = line.split(': ')[1]
channelId = line.split(infix)[1].split(' (')[0]
threads[threadId] = channelId
for threadId in threads:
channelId = threads[threadId]
print(threadId, channelId)
shutil.rmtree(path + channelId)