From 35f1e34e3f3ff9c1ce4aae4379395eaed49d759a Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Mon, 10 Mar 2025 06:37:34 -0600 Subject: Starting to really change the website --- scripts/youtube_subs_export.py | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 scripts/youtube_subs_export.py (limited to 'scripts') diff --git a/scripts/youtube_subs_export.py b/scripts/youtube_subs_export.py new file mode 100644 index 0000000..6a36840 --- /dev/null +++ b/scripts/youtube_subs_export.py @@ -0,0 +1,51 @@ +import sys + +""" +This little script lets you export your entire youtube subscriptions list to a opml file. + +To use it go to your google account and go to your user data collection and find the part on youtube to download your subscriptions. +It will give you a subscriptions.csv file and pass that file to the script and it will output the rss opml data to stdout. +Do what you need with that data. +""" + +# XML doesn't like some characters +def fix_name(name): + no_no_list = ["\n", '"', "&"] + name = "".join(filter(lambda x: x not in no_no_list, name)) + return name + +def main(): + + # Get name of the csv file. + if len(sys.argv) < 1: + print("File name required") + sys.exit() + + file_name = sys.argv[1] + + with open(file_name, "r") as fp: + + print('') + print('') + print('OPML Feeds') + print('') + + for line in fp.readlines()[1::]: # Skips the first line. + + # Empty line. + if line == "\n": + continue + + line_data = line.split(",") + feed_url = f"https://www.youtube.com/feeds/videos.xml?channel_id={line_data[0]}" + + print(f'\t') + + + print('') + print('') + + +if __name__ == "__main__": + main() + -- cgit v1.2.3