diff --git a/Makefile b/Makefile index 33deb371165b835fb7bd80c14aecd01fbae7ce50..d3554431ce1690bc9524c80e6de85034b2088791 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,7 @@ version: debug: env DEBUG=1 $(PYTHON) m3u8downloader/main.py run: - $(PYTHON) m3u8downloader/main.py $(OFILE) $(URL) -t1: - $(PYTHON) m3u8downloader/t1.py + $(PYTHON) m3u8downloader/main.py -o $(OFILE) $(URL) uwsgi: $(VENV)/bin/uwsgi --processes=2 --threads=4 --wsgi-file=m3u8downloader/main.py --env=PYTHONPATH=. --http=localhost:8082 --disable-logging shell: diff --git a/m3u8downloader/__init__.py b/m3u8downloader/__init__.py index d3ec452c319b475c6661b100f2dd22ca031ed911..493f7415d73d5d2a0875222a1c7296000935cccc 100644 --- a/m3u8downloader/__init__.py +++ b/m3u8downloader/__init__.py @@ -1 +1 @@ -__version__ = "0.2.0" +__version__ = "0.3.0" diff --git a/m3u8downloader/main.py b/m3u8downloader/main.py index 0c5b9f8701d60447e4c374de6ea4e53ad6f5cf10..0f012c46edfbe71974673e36f268ebe05c6c60a1 100644 --- a/m3u8downloader/main.py +++ b/m3u8downloader/main.py @@ -12,6 +12,7 @@ Features: from __future__ import print_function, unicode_literals +import argparse import sys import os import os.path @@ -277,18 +278,16 @@ class M3u8Downloader: def main(): - try: - ofile = sys.argv[1] - url = sys.argv[2] - if len(sys.argv) > 3: - tempdir = sys.argv[3] - else: - tempdir = get_fullpath('~/.cache/m3u8downloader') - except IndexError: - logger.error("Usage: m3u8 OUTPUT_FILE URL") - sys.exit(1) + parser = argparse.ArgumentParser(description="download video at m3u8 url") + parser.add_argument('--output', '-o', help='target video filename') + parser.add_argument( + '--tempdir', default='~/.cache/m3u8downloader', + help='temp dir, used to store .ts files before combing them into mp4') + parser.add_argument('url', help='the m3u8 url') + args = parser.parse_args() + SESSION.headers.update({'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36'}) - downloader = M3u8Downloader(url, ofile, tempdir) + downloader = M3u8Downloader(args.url, args.output, args.tempdir) downloader.start() diff --git a/setup.py b/setup.py index 9aebeca744b05f1f15dab525c15525b50b237fb8..8317316f172286a22e69c8b86b0c3b88a27f2273 100644 --- a/setup.py +++ b/setup.py @@ -40,15 +40,14 @@ setup( author_email="sylecn@gmail.com", maintainer="Yuanle Song", maintainer_email="sylecn@gmail.com", - description="FIXME add description", + description="a cli program to download video at m3u8 url", long_description=open('README.rst').read(), license="GPLv2+", url="https://pypi.python.org/pypi/m3u8downloader", classifiers=[ - 'Development Status :: 3 - Alpha', + 'Development Status :: 4 - Beta', 'License :: OSI Approved :: GNU General Public License (GPL)', 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', - # 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', ] )