Skip to content

Commit 13d40fa

Browse files
committed
Major refactoring
* Change entry point to you_get.__main__:main * New entry point for development (you-get-dev): you_get.__main__:main_dev * you_get.extractor -> you_get.extractors
1 parent c1f3340 commit 13d40fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+424
-297
lines changed

src/you_get/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#!/usr/bin/env python
2+
# This file is Python 2 compliant.
23

3-
from .common import *
4-
from .version import *
4+
import sys
55

6-
from .cli_wrapper import *
7-
from .extractor import *
6+
if sys.version_info[0] == 3:
7+
#from .extractor import Extractor, VideoExtractor
8+
#from .util import log
9+
10+
from .__main__ import *
11+
12+
#from .common import *
13+
#from .version import *
14+
#from .cli_wrapper import *
15+
#from .extractor import *
16+
else:
17+
# Don't import anything.
18+
pass

src/you_get/__main__.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env python
2+
3+
import getopt
4+
import os
5+
import platform
6+
import sys
7+
from .version import script_name, __version__
8+
from .util import git, log
9+
10+
_options = [
11+
'help',
12+
'version',
13+
'gui',
14+
'force',
15+
'playlists',
16+
]
17+
_short_options = 'hVgfl'
18+
19+
_help = """Usage: {} [OPTION]... [URL]...
20+
TODO
21+
""".format(script_name)
22+
23+
def main_dev(**kwargs):
24+
"""Main entry point.
25+
you-get-dev
26+
"""
27+
28+
# Get (branch, commit) if running from a git repo.
29+
head = git.get_head(kwargs['repo_path'])
30+
31+
# Get options and arguments.
32+
try:
33+
opts, args = getopt.getopt(sys.argv[1:], _short_options, _options)
34+
except getopt.GetoptError as e:
35+
log.wtf("""
36+
[Fatal] {}.
37+
Try '{} --help' for more options.""".format(e, script_name))
38+
39+
if not opts and not args:
40+
# Display help.
41+
print(_help)
42+
# Enter GUI mode.
43+
#from .gui import gui_main
44+
#gui_main()
45+
else:
46+
conf = {}
47+
for opt, arg in opts:
48+
if opt in ('-h', '--help'):
49+
# Display help.
50+
print(_help)
51+
52+
elif opt in ('-V', '--version'):
53+
# Display version.
54+
log.println("you-get:", log.BOLD)
55+
log.println(" version: {}".format(__version__))
56+
if head is not None:
57+
log.println(" branch: {}\n commit: {}".format(*head))
58+
else:
59+
log.println(" branch: {}\n commit: {}".format("(stable)", "(tag v{})".format(__version__)))
60+
61+
log.println(" platform: {}".format(platform.platform()))
62+
log.println(" python: {}".format(sys.version.split('\n')[0]))
63+
64+
elif opt in ('-g', '--gui'):
65+
# Run using GUI.
66+
conf['gui'] = True
67+
68+
elif opt in ('-f', '--force'):
69+
# Force download.
70+
conf['force'] = True
71+
72+
elif opt in ('-l', '--playlist', '--playlists'):
73+
# Download playlist whenever possible.
74+
conf['playlist'] = True
75+
76+
if args:
77+
if 'gui' in conf and conf['gui']:
78+
# Enter GUI mode.
79+
from .gui import gui_main
80+
gui_main(*args, **conf)
81+
else:
82+
# Enter console mode.
83+
from .console import console_main
84+
console_main(*args, **conf)
85+
86+
def main(**kwargs):
87+
"""Main entry point.
88+
you-get (legacy)
89+
"""
90+
from .common import main
91+
main()

0 commit comments

Comments
 (0)