Add {removeChannelsBeingTreated, findTreatedChannelWithMost{Comments, Subscribers}}.py
This commit is contained in:
parent
e4b4ce21a2
commit
4cae7e09d1
16
findTreatedChannelWithMostComments.py
Normal file
16
findTreatedChannelWithMostComments.py
Normal 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)
|
23
findTreatedChannelWithMostSubscribers.py
Normal file
23
findTreatedChannelWithMostSubscribers.py
Normal 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)
|
23
removeChannelsBeingTreated.py
Normal file
23
removeChannelsBeingTreated.py
Normal 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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user