mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 05:25:02 +03:00
refactor for Python packaging
This commit is contained in:
parent
e71972d4a1
commit
70cb82b703
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,7 +1,11 @@
|
||||
_*
|
||||
/build/
|
||||
/dist/
|
||||
|
||||
_*/
|
||||
*.py[cod]
|
||||
|
||||
*.download
|
||||
*.3gp
|
||||
*.flv
|
||||
*.mp4
|
||||
*.webm
|
||||
|
2
CHANGELOG.txt
Normal file
2
CHANGELOG.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Changelog
|
||||
=========
|
21
MANIFEST
Normal file
21
MANIFEST
Normal file
@ -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
|
5
MANIFEST.in
Normal file
5
MANIFEST.in
Normal file
@ -0,0 +1,5 @@
|
||||
include *.txt
|
||||
include Makefile
|
||||
include README.md
|
||||
include you-get
|
||||
include you-get.json
|
18
Makefile
Normal file
18
Makefile
Normal file
@ -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
|
2
README.txt
Normal file
2
README.txt
Normal file
@ -0,0 +1,2 @@
|
||||
You-Get
|
||||
=======
|
30
setup.py
Executable file
30
setup.py
Executable file
@ -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']
|
||||
)
|
6
you-get
6
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)
|
||||
|
50
you-get.json
50
you-get.json
@ -1,19 +1,39 @@
|
||||
{
|
||||
"name": "you-get",
|
||||
"version": "0.0.1",
|
||||
"date": "2012-08-20",
|
||||
"author": "Mort Yao <mort.yao@gmail.com>",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
|
7
you_get/__init__.py
Normal file
7
you_get/__init__.py
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
from .processor import *
|
||||
from .downloader import *
|
||||
from .main import *
|
||||
from .common import script_main
|
||||
|
||||
__version__ = common.proj_info['version']
|
@ -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:
|
5
you_get/downloader/__init__.py
Normal file
5
you_get/downloader/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
from .tudou import *
|
||||
from .yinyuetai import *
|
||||
from .youku import *
|
||||
from .youtube import *
|
@ -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)
|
@ -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)
|
@ -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)
|
@ -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)
|
@ -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)
|
5
you_get/processor/__init__.py
Normal file
5
you_get/processor/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
__all__ = ['concat_flvs', 'concat_mp4s']
|
||||
|
||||
from .merge_flv import concat_flvs
|
||||
from .merge_mp4 import concat_mp4s
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
|
||||
import struct
|
||||
from io import BytesIO
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
|
||||
# reference: c041828_ISO_IEC_14496-12_2005(E).pdf
|
||||
|
Loading…
Reference in New Issue
Block a user