diff options
author | Rogério Brito <rbrito@ime.usp.br> | 2012-12-18 09:14:17 -0200 |
---|---|---|
committer | Rogério Brito <rbrito@ime.usp.br> | 2012-12-18 09:14:17 -0200 |
commit | 65cc51b0a1ddf217bc2026332532e0f8019c158a (patch) | |
tree | d79c57ceaef41baf90599e172d59e7a1cdb1b52d /devscripts | |
parent | 620116f59230cf52cae4eedf98c39f7214897e3c (diff) | |
download | youtube-dl-65cc51b0a1ddf217bc2026332532e0f8019c158a.zip youtube-dl-65cc51b0a1ddf217bc2026332532e0f8019c158a.tar.gz youtube-dl-65cc51b0a1ddf217bc2026332532e0f8019c158a.tar.bz2 |
Imported Upstream version 2012.12.11
Diffstat (limited to 'devscripts')
-rw-r--r-- | devscripts/bash-completion.py | 26 | ||||
-rw-r--r-- | devscripts/bash-completion.template | 14 | ||||
-rw-r--r-- | devscripts/make_readme.py | 20 | ||||
-rwxr-xr-x[-rw-r--r--] | devscripts/posix-locale.sh | 0 | ||||
-rwxr-xr-x | devscripts/release.sh | 11 | ||||
-rw-r--r-- | devscripts/transition_helper.py | 40 | ||||
-rw-r--r-- | devscripts/transition_helper_exe/setup.py | 12 | ||||
-rw-r--r-- | devscripts/transition_helper_exe/youtube-dl.py | 49 | ||||
-rwxr-xr-x[-rw-r--r--] | devscripts/wine-py2exe.sh | 0 |
9 files changed, 172 insertions, 0 deletions
diff --git a/devscripts/bash-completion.py b/devscripts/bash-completion.py new file mode 100644 index 0000000..880db78 --- /dev/null +++ b/devscripts/bash-completion.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +import os +from os.path import dirname as dirn +import sys + +sys.path.append(dirn(dirn((os.path.abspath(__file__))))) +import youtube_dl + +BASH_COMPLETION_FILE = "youtube-dl.bash-completion" +BASH_COMPLETION_TEMPLATE = "devscripts/bash-completion.template" + +def build_completion(opt_parser): + opts_flag = [] + for group in opt_parser.option_groups: + for option in group.option_list: + #for every long flag + opts_flag.append(option.get_opt_string()) + with open(BASH_COMPLETION_TEMPLATE) as f: + template = f.read() + with open(BASH_COMPLETION_FILE, "w") as f: + #just using the special char + filled_template = template.replace("{{flags}}", " ".join(opts_flag)) + f.write(filled_template) + +parser = youtube_dl.parseOpts()[0] +build_completion(parser) diff --git a/devscripts/bash-completion.template b/devscripts/bash-completion.template new file mode 100644 index 0000000..3b99a96 --- /dev/null +++ b/devscripts/bash-completion.template @@ -0,0 +1,14 @@ +__youtube-dl() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + opts="{{flags}}" + + if [[ ${cur} == * ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi +} + +complete -F __youtube-dl youtube-dl diff --git a/devscripts/make_readme.py b/devscripts/make_readme.py new file mode 100644 index 0000000..7f2ea31 --- /dev/null +++ b/devscripts/make_readme.py @@ -0,0 +1,20 @@ +import sys +import re + +README_FILE = 'README.md' +helptext = sys.stdin.read() + +with open(README_FILE) as f: + oldreadme = f.read() + +header = oldreadme[:oldreadme.index('# OPTIONS')] +footer = oldreadme[oldreadme.index('# CONFIGURATION'):] + +options = helptext[helptext.index(' General Options:')+19:] +options = re.sub(r'^ (\w.+)$', r'## \1', options, flags=re.M) +options = '# OPTIONS\n' + options + '\n' + +with open(README_FILE, 'w') as f: + f.write(header) + f.write(options) + f.write(footer) diff --git a/devscripts/posix-locale.sh b/devscripts/posix-locale.sh index 0aa7a59..0aa7a59 100644..100755 --- a/devscripts/posix-locale.sh +++ b/devscripts/posix-locale.sh diff --git a/devscripts/release.sh b/devscripts/release.sh new file mode 100755 index 0000000..963a6c2 --- /dev/null +++ b/devscripts/release.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi +version="$1" +if [ ! -z "`git tag | grep "$version"`" ]; then echo 'ERROR: version already present'; exit 1; fi +if [ ! -z "`git status --porcelain`" ]; then echo 'ERROR: the working directory is not clean; commit or stash changes'; exit 1; fi +sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/__init__.py +make all +git add -A +git commit -m "release $version" +git tag -m "Release $version" "$version"
\ No newline at end of file diff --git a/devscripts/transition_helper.py b/devscripts/transition_helper.py new file mode 100644 index 0000000..d5ca2d4 --- /dev/null +++ b/devscripts/transition_helper.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +import sys, os + +try: + import urllib.request as compat_urllib_request +except ImportError: # Python 2 + import urllib2 as compat_urllib_request + +sys.stderr.write(u'Hi! We changed distribution method and now youtube-dl needs to update itself one more time.\n') +sys.stderr.write(u'This will only happen once. Simply press enter to go on. Sorry for the trouble!\n') +sys.stderr.write(u'The new location of the binaries is https://github.com/rg3/youtube-dl/downloads, not the git repository.\n\n') + +try: + raw_input() +except NameError: # Python 3 + input() + +filename = sys.argv[0] + +API_URL = "https://api.github.com/repos/rg3/youtube-dl/downloads" +BIN_URL = "https://github.com/downloads/rg3/youtube-dl/youtube-dl" + +if not os.access(filename, os.W_OK): + sys.exit('ERROR: no write permissions on %s' % filename) + +try: + urlh = compat_urllib_request.urlopen(BIN_URL) + newcontent = urlh.read() + urlh.close() +except (IOError, OSError) as err: + sys.exit('ERROR: unable to download latest version') + +try: + with open(filename, 'wb') as outf: + outf.write(newcontent) +except (IOError, OSError) as err: + sys.exit('ERROR: unable to overwrite current version') + +sys.stderr.write(u'Done! Now you can run youtube-dl.\n') diff --git a/devscripts/transition_helper_exe/setup.py b/devscripts/transition_helper_exe/setup.py new file mode 100644 index 0000000..aaf5c29 --- /dev/null +++ b/devscripts/transition_helper_exe/setup.py @@ -0,0 +1,12 @@ +from distutils.core import setup +import py2exe + +py2exe_options = { + "bundle_files": 1, + "compressed": 1, + "optimize": 2, + "dist_dir": '.', + "dll_excludes": ['w9xpopen.exe'] +} + +setup(console=['youtube-dl.py'], options={ "py2exe": py2exe_options }, zipfile=None)
\ No newline at end of file diff --git a/devscripts/transition_helper_exe/youtube-dl.py b/devscripts/transition_helper_exe/youtube-dl.py new file mode 100644 index 0000000..409f980 --- /dev/null +++ b/devscripts/transition_helper_exe/youtube-dl.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import sys, os +import urllib2 + +sys.stderr.write(u'Hi! We changed distribution method and now youtube-dl needs to update itself one more time.\n') +sys.stderr.write(u'This will only happen once. Simply press enter to go on. Sorry for the trouble!\n') +sys.stderr.write(u'The new location of the binaries is https://github.com/rg3/youtube-dl/downloads, not the git repository.\n\n') + +raw_input() + +filename = sys.argv[0] + +API_URL = "https://api.github.com/repos/rg3/youtube-dl/downloads" +EXE_URL = "https://github.com/downloads/rg3/youtube-dl/youtube-dl.exe" + +if not os.access(filename, os.W_OK): + sys.exit('ERROR: no write permissions on %s' % filename) + +exe = os.path.abspath(filename) +directory = os.path.dirname(exe) +if not os.access(directory, os.W_OK): + sys.exit('ERROR: no write permissions on %s' % directory) + +try: + urlh = urllib2.urlopen(EXE_URL) + newcontent = urlh.read() + urlh.close() + with open(exe + '.new', 'wb') as outf: + outf.write(newcontent) +except (IOError, OSError) as err: + sys.exit('ERROR: unable to download latest version') + +try: + bat = os.path.join(directory, 'youtube-dl-updater.bat') + b = open(bat, 'w') + b.write(""" +echo Updating youtube-dl... +ping 127.0.0.1 -n 5 -w 1000 > NUL +move /Y "%s.new" "%s" +del "%s" + \n""" %(exe, exe, bat)) + b.close() + + os.startfile(bat) +except (IOError, OSError) as err: + sys.exit('ERROR: unable to overwrite current version') + +sys.stderr.write(u'Done! Now you can run youtube-dl.\n') diff --git a/devscripts/wine-py2exe.sh b/devscripts/wine-py2exe.sh index dc2d650..dc2d650 100644..100755 --- a/devscripts/wine-py2exe.sh +++ b/devscripts/wine-py2exe.sh |