config/misc/youtube_subscription_parser.py
2021-02-11 09:03:17 +10:30

23 lines
588 B
Python
Executable File

import json
import os
import hashlib
subscriptions = {}
channels = []
# read subscirptions from google takeout file
with open('./subscriptions.json') as f:
doc = json.load(f)
subscriptions[u'all'] = doc
# create a list of channels using id
for subscription in subscriptions.values():
for snippet in subscription:
channels.append('https://www.youtube.com/feeds/videos.xml?channel_id=' + snippet['snippet']['resourceId']['channelId'] + '\n')
# write subscription urls to file
with open('urls', 'a') as f:
for channel in channels:
f.writelines(channel)