diff --git a/.gitignore b/.gitignore index 1a8a5438..6e31ba6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ -_* +/build/ +/dist/ + +_*/ *.py[cod] *.download +*.3gp *.flv *.mp4 *.webm diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 00000000..a5693d97 --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,2 @@ +Changelog +========= diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 00000000..d5dab196 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,21 @@ +# file GENERATED by distutils, do NOT edit +CHANGELOG.txt +LICENSE.txt +Makefile +README.md +README.txt +setup.cfg +setup.py +you-get +you-get.json +you_get/__init__.py +you_get/common.py +you_get/main.py +you_get/downloader/__init__.py +you_get/downloader/tudou.py +you_get/downloader/yinyuetai.py +you_get/downloader/youku.py +you_get/downloader/youtube.py +you_get/processor/__init__.py +you_get/processor/merge_flv.py +you_get/processor/merge_mp4.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..d25c879e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include *.txt +include Makefile +include README.md +include you-get +include you-get.json diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e31e637a --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +default: install sdist bdist + +clean: + rm -fr build/ dist/ + +build: + python3 setup.py build + +install: build + sudo python3 setup.py install + +sdist: + python3 setup.py sdist + +bdist: + python3 setup.py bdist + +.PHONY: default clean build install sdist bdist diff --git a/README.txt b/README.txt new file mode 100644 index 00000000..f7c714bb --- /dev/null +++ b/README.txt @@ -0,0 +1,2 @@ +You-Get +======= diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..cd83a406 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[build] +force=0 + +[global] +verbose=0 diff --git a/setup.py b/setup.py new file mode 100755 index 00000000..8c34e382 --- /dev/null +++ b/setup.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +PROJ_METADATA = 'you-get.json' + +import os, json + +here = os.path.abspath(os.path.dirname(__file__)) +proj_info = json.loads(open(os.path.join(here, PROJ_METADATA)).read()) +README = open(os.path.join(here, 'README.txt')).read() +CHANGELOG = open(os.path.join(here, 'CHANGELOG.txt')).read() + +from distutils.core import setup +setup( + name = proj_info['name'], + version = proj_info['version'], + + author = proj_info['author'], + author_email = proj_info['author_email'], + url = proj_info['url'], + download_url = proj_info['download_url'], + license = proj_info['license'], + + description = proj_info['description'], + keywords = proj_info['keywords'], + long_description = README + '\n\n' + CHANGELOG, + + packages = proj_info['packages'], + + classifiers = proj_info['classifiers'] +) diff --git a/you-get b/you-get index 76023f77..7edfee89 100755 --- a/you-get +++ b/you-get @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from get import * +from you_get import * -if __name__ == '__main__': - main('you-get', any_download, any_download_playlist) +if __name__ == "__main__": + script_main('you-get', any_download, any_download_playlist) diff --git a/you-get.json b/you-get.json index 89ebc85d..1894c555 100644 --- a/you-get.json +++ b/you-get.json @@ -1,19 +1,39 @@ { + "name": "you-get", "version": "0.0.1", "date": "2012-08-20", - "author": "Mort Yao ", - "file_list": [ - "LICENSE", - "README.md", - "common.py", - "get.py", - "get_tudou.py", - "get_yinyuetai.py", - "get_youku.py", - "get_youtube.py", - "merge_flv.py", - "merge_mp4.py", - "you-get", - "you-get.json" - ] + + "author": "Mort Yao", + "author_email": "mort.yao@gmail.com", + "url": "http://www.soimort.org/you-get/", + "download_url": "https://github.com/soimort/you-get/zipball/master", + "license": "MIT", + + "description": "A YouTube/Youku video downloader written in Python 3.", + "keywords": "video download youtube youku", + + "packages": [ + "you_get", + "you_get.downloader", + "you_get.processor" + ], + + "classifiers": [ + "Development Status :: 1 - Planning", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.2", + "Topic :: Internet", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Multimedia", + "Topic :: Multimedia :: Video", + "Topic :: Utilities" + ] } diff --git a/you_get/__init__.py b/you_get/__init__.py new file mode 100644 index 00000000..73b11c29 --- /dev/null +++ b/you_get/__init__.py @@ -0,0 +1,7 @@ + +from .processor import * +from .downloader import * +from .main import * +from .common import script_main + +__version__ = common.proj_info['version'] diff --git a/common.py b/you_get/common.py similarity index 98% rename from common.py rename to you_get/common.py index 76615812..8d12b184 100644 --- a/common.py +++ b/you_get/common.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 import getopt import json @@ -295,12 +294,12 @@ def download_urls(urls, title, ext, total_size, output_dir = '.', refer = None, if not merge: return if ext == 'flv': - from merge_flv import concat_flvs + from .processor.merge_flv import concat_flvs concat_flvs(flvs, os.path.join(output_dir, title + '.flv')) for flv in flvs: os.remove(flv) elif ext == 'mp4': - from merge_mp4 import concat_mp4s + from .processor.merge_mp4 import concat_mp4s concat_mp4s(flvs, os.path.join(output_dir, title + '.mp4')) for flv in flvs: os.remove(flv) @@ -360,7 +359,7 @@ def set_http_proxy(proxy): opener = request.build_opener(proxy_support) request.install_opener(opener) -def main(script_name, download, download_playlist = None): +def script_main(script_name, download, download_playlist = None): version = 'You-Get %s, a video downloader.' % proj_info['version'] help = 'Usage: [python3] %s [OPTION]... [URL]...\n' % script_name help += '''\nStartup options: diff --git a/you_get/downloader/__init__.py b/you_get/downloader/__init__.py new file mode 100644 index 00000000..259bcc18 --- /dev/null +++ b/you_get/downloader/__init__.py @@ -0,0 +1,5 @@ + +from .tudou import * +from .yinyuetai import * +from .youku import * +from .youtube import * diff --git a/get_tudou.py b/you_get/downloader/tudou.py similarity index 96% rename from get_tudou.py rename to you_get/downloader/tudou.py index 05c99f8f..e8ce5c29 100755 --- a/get_tudou.py +++ b/you_get/downloader/tudou.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python __all__ = ['tudou_download', 'tudou_download_playlist', 'tudou_download_by_id', 'tudou_download_by_iid'] -from common import * +from ..common import * def tudou_download_by_iid(iid, title, output_dir = '.', merge = True, info_only = False): xml = get_html('http://v2.tudou.com/v?it=' + iid + '&st=1,2,3,4,99') @@ -73,4 +73,4 @@ download = tudou_download download_playlist = tudou_download_playlist if __name__ == '__main__': - main('tudou', tudou_download, tudou_download_playlist) + script_main('tudou.py', tudou_download, tudou_download_playlist) diff --git a/get_yinyuetai.py b/you_get/downloader/yinyuetai.py similarity index 93% rename from get_yinyuetai.py rename to you_get/downloader/yinyuetai.py index b5953bb9..10c3f776 100755 --- a/get_yinyuetai.py +++ b/you_get/downloader/yinyuetai.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python __all__ = ['yinyuetai_download', 'yinyuetai_download_by_id'] -from common import * +from ..common import * def yinyuetai_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False): assert title @@ -33,4 +33,4 @@ download = yinyuetai_download download_playlist = playlist_not_supported('yinyuetai') if __name__ == '__main__': - main('get_yinyuetai.py', yinyuetai_download) + script_main('yinyuetai.py', yinyuetai_download) diff --git a/get_youku.py b/you_get/downloader/youku.py similarity index 98% rename from get_youku.py rename to you_get/downloader/youku.py index 0929c886..98324b3c 100755 --- a/get_youku.py +++ b/you_get/downloader/youku.py @@ -1,9 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # -*- coding: utf-8 -*- __all__ = ['youku_download', 'youku_download_playlist', 'youku_download_by_id'] -from common import * +from ..common import * import json from random import randint @@ -198,4 +198,4 @@ download = youku_download download_playlist = youku_download_playlist if __name__ == '__main__': - main('get_youku.py', youku_download, youku_download_playlist) + script_main('youku.py', youku_download, youku_download_playlist) diff --git a/get_youtube.py b/you_get/downloader/youtube.py similarity index 93% rename from get_youtube.py rename to you_get/downloader/youtube.py index 747c6fac..ef6d5983 100755 --- a/get_youtube.py +++ b/you_get/downloader/youtube.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python __all__ = ['youtube_download', 'youtube_download_by_id'] -from common import * +from ..common import * def youtube_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False): try: @@ -33,4 +33,4 @@ download = youtube_download download_playlist = playlist_not_supported('youtube') if __name__ == '__main__': - main('get_youtube.py', youtube_download) + script_main('youtube.py', youtube_download) diff --git a/get.py b/you_get/main.py similarity index 57% rename from get.py rename to you_get/main.py index 11f17da3..315c9e19 100755 --- a/get.py +++ b/you_get/main.py @@ -1,10 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python -from common import * -import get_tudou -import get_yinyuetai -import get_youku -import get_youtube +__all__ = ['any_download', 'any_download_playlist'] + +from .downloader import * +from .common import * def url_to_module(url): site = r1(r'http://([^/]+)/', url) @@ -17,22 +16,22 @@ def url_to_module(url): k = r1(r'([^.]+)', domain) downloads = { - 'youtube': get_youtube, - 'youku': get_youku, - 'yinyuetai': get_yinyuetai, - 'tudou': get_tudou, + 'youtube': youtube, + 'youku': youku, + 'yinyuetai': yinyuetai, + 'tudou': tudou, #TODO: - # 'acfun': get_acfun, - # 'bilibili': get_bilibili, - # 'kankanews': get_bilibili, - # 'iask': get_iask, - # 'sina': get_iask, - # 'ku6': get_ku6, - # 'pptv': get_pptv, - # 'iqiyi': get_iqiyi, - # 'sohu': get_sohu, - # '56': get_w56, - # 'cntv': get_cntv, + # 'acfun': acfun, + # 'bilibili': bilibili, + # 'kankanews': bilibili, + # 'iask': iask, + # 'sina': iask, + # 'ku6': ku6, + # 'pptv': pptv, + # 'iqiyi': iqiyi, + # 'sohu': sohu, + # '56': w56, + # 'cntv': cntv, } if k in downloads: return downloads[k] @@ -48,4 +47,4 @@ def any_download_playlist(url, output_dir = '.', merge = True, info_only = False m.download_playlist(url, output_dir = output_dir, merge = merge, info_only = info_only) if __name__ == '__main__': - main('get.py', any_download, any_download_playlist) + script_main('main.py', any_download, any_download_playlist) diff --git a/you_get/processor/__init__.py b/you_get/processor/__init__.py new file mode 100644 index 00000000..6f0b2aed --- /dev/null +++ b/you_get/processor/__init__.py @@ -0,0 +1,5 @@ + +__all__ = ['concat_flvs', 'concat_mp4s'] + +from .merge_flv import concat_flvs +from .merge_mp4 import concat_mp4s diff --git a/merge_flv.py b/you_get/processor/merge_flv.py similarity index 99% rename from merge_flv.py rename to you_get/processor/merge_flv.py index f2a0dcbe..ce890837 100755 --- a/merge_flv.py +++ b/you_get/processor/merge_flv.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python import struct from io import BytesIO diff --git a/merge_mp4.py b/you_get/processor/merge_mp4.py similarity index 99% rename from merge_mp4.py rename to you_get/processor/merge_mp4.py index 5b551c38..0139dd26 100755 --- a/merge_mp4.py +++ b/you_get/processor/merge_mp4.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # reference: c041828_ISO_IEC_14496-12_2005(E).pdf