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

This commit is contained in:
Benjamin Loison 2023-01-04 02:41:07 +01:00
parent e4b4ce21a2
commit 4cae7e09d1
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8
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)