From 55578f4de7e88d84b4b074a28c35a1664d49d390 Mon Sep 17 00:00:00 2001 From: meeb Date: Fri, 18 Dec 2020 17:31:47 +1100 Subject: [PATCH] add pretty-json-info-spam wrapper command to aid debugging urls --- tubesync/sync/management/__init__.py | 0 tubesync/sync/management/commands/__init__.py | 0 .../management/commands/youtube-dl-info.py | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 tubesync/sync/management/__init__.py create mode 100644 tubesync/sync/management/commands/__init__.py create mode 100644 tubesync/sync/management/commands/youtube-dl-info.py diff --git a/tubesync/sync/management/__init__.py b/tubesync/sync/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tubesync/sync/management/commands/__init__.py b/tubesync/sync/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tubesync/sync/management/commands/youtube-dl-info.py b/tubesync/sync/management/commands/youtube-dl-info.py new file mode 100644 index 00000000..310b10d4 --- /dev/null +++ b/tubesync/sync/management/commands/youtube-dl-info.py @@ -0,0 +1,18 @@ +import json +from django.core.management.base import BaseCommand, CommandError +from sync.youtube import get_media_info + + +class Command(BaseCommand): + + help = 'Displays information obtained by youtube-dl in JSON to the console' + + def add_arguments(self, parser): + parser.add_argument('url', type=str) + + def handle(self, *args, **options): + url = options['url'] + self.stdout.write(f'Showing information for URL: {url}') + info = get_media_info(url) + self.stdout.write(json.dumps(info, indent=4, sort_keys=True)) + self.stdout.write('Done')