diff --git a/README.md b/README.md index ec5d7ac..18dd8ae 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,19 @@ python twspace_dl/main.py space_id ## Features Here's the output of the help option ``` -usage: main.py [-h] [-v] [-m] [-w] [-u] [-s] [-k] SPACE_ID +usage: main.py [-h] [-i SPACE_ID] [-f URL] [-v] [-m] [-w] [-u] [-s] [-k] Script designed to help download twitter spaces -positional arguments: - SPACE_ID - optional arguments: -h, --help show this help message and exit + -i SPACE_ID, --space-id SPACE_ID + -f URL, --from-url URL + use the master url for the processes(useful for ended spaces) -v, --verbose -m, --write-metadata -w, --write-playlist write the m3u8 used to download the stream - -u, --url display the final url + -u, --url display the master url -s, --skip-download -k, --keep-files ``` diff --git a/twspace_dl/main.py b/twspace_dl/main.py index 72f8a3f..a73ae08 100644 --- a/twspace_dl/main.py +++ b/twspace_dl/main.py @@ -136,7 +136,7 @@ def merge(self) -> None: f"{self.title}-{self.id}-tmp.aac", "-c", "copy", - f"{self.title}-{self.id}.aac", + f"./{self.title}-{self.id}.aac", ] subprocess.run(command, check=True) logging.info("finished merging") @@ -167,7 +167,14 @@ def download(self) -> None: parser = argparse.ArgumentParser( description="Script designed to help download twitter spaces" ) - parser.add_argument("space_id", type=str, metavar="SPACE_ID") + parser.add_argument("-i", "--space-id", type=str, metavar="SPACE_ID") + parser.add_argument( + "-f", + "--from-url", + type=str, + metavar="URL", + help="use the master url for the processes(useful for ended spaces)", + ) parser.add_argument("-v", "--verbose", action="store_true") parser.add_argument("-m", "--write-metadata", action="store_true") parser.add_argument( @@ -177,7 +184,7 @@ def download(self) -> None: help="write the m3u8 used to download the stream", ) parser.add_argument( - "-u", "--url", action="store_true", help="display the final url" + "-u", "--url", action="store_true", help="display the master url" ) parser.add_argument("-s", "--skip-download", action="store_true") parser.add_argument("-k", "--keep-files", action="store_true") @@ -185,17 +192,19 @@ def download(self) -> None: parser.print_help(sys.stderr) sys.exit(1) args = parser.parse_args() - if not args.space_id: - print("ID is required") + if not args.space_id and not args.from_url: + print("Either space id or final url should be provided") sys.exit(1) logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) twspace_dl = TwspaceDL(args.space_id) + if args.from_url: + twspace_dl.master_url = args.from_url if args.write_metadata: twspace_dl.write_metadata() if args.url: - print(twspace_dl.playlist_url) + print(twspace_dl.master_url) if args.write_playlist: twspace_dl.write_playlist() if not args.skip_download: