From 7d575ee382482075304b61d336424e1887c33306 Mon Sep 17 00:00:00 2001 From: qnorsten Date: Thu, 5 May 2016 10:38:43 +0200 Subject: [PATCH 1/8] get_one_media: added missing checks if subtitles exists before trying to print url using -g --- lib/svtplay_dl/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/svtplay_dl/__init__.py b/lib/svtplay_dl/__init__.py index c988c91..ecb3530 100644 --- a/lib/svtplay_dl/__init__.py +++ b/lib/svtplay_dl/__init__.py @@ -224,11 +224,12 @@ def get_one_media(stream, options): return if options.subtitle and options.get_url: - if options.get_all_subtitles: - for sub in subs: - print(sub.url) - else: - print(subs[0].url) + if subs: + if options.get_all_subtitles: + for sub in subs: + print(sub.url) + else: + print(subs[0].url) if options.force_subtitle: return From 7a29dcb65aa25c9e68cf62f98b3fb9c133f3bbd9 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Wed, 4 May 2016 14:16:59 +0200 Subject: [PATCH 2/8] Add a silent-semi argument It that will only print error, warning and when the file is downloaded. --- lib/svtplay_dl/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/svtplay_dl/__init__.py b/lib/svtplay_dl/__init__.py index ecb3530..8c329ed 100644 --- a/lib/svtplay_dl/__init__.py +++ b/lib/svtplay_dl/__init__.py @@ -136,12 +136,15 @@ class Options(object): self.stream_prio = None self.remux = False self.get_all_subtitles = False + self.silent_semi = False def get_media(url, options): if "http" not in url[:4]: url = "http://%s" % url + if options.silent_semi: + options.silent = True stream = service_handler(sites, options, url) if not stream: generic = Generic(options, url) @@ -278,13 +281,16 @@ def get_one_media(stream, options): log.warning("Cant find ffmpeg/avconv. audio and video is in seperate files. if you dont want this use -P hls or hds") if options.remux: post.remux() + if options.silent_semi and stream.finished: + log.log(25, "Download of %s was completed" % stream.options.output) def setup_log(silent, verbose=False): + logging.addLevelName(25, "INFO") fmt = logging.Formatter('%(levelname)s: %(message)s') if silent: stream = sys.stderr - level = logging.WARNING + level = 25 elif verbose: stream = sys.stderr level = logging.DEBUG @@ -318,6 +324,8 @@ def main(): parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="be less verbose") + parser.add_option("--silent-semi", action="store_true", + dest="silent_semi", default=False, help="only show a message when the file is downloaded") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="explain what is going on") @@ -377,6 +385,8 @@ def main(): if options.require_subtitle: options.subtitle = True options = mergeParserOption(Options(), options) + if options.silent_semi: + options.silent = True setup_log(options.silent, options.verbose) if options.flexibleq and not options.quality: @@ -401,6 +411,7 @@ def mergeParserOption(options, parser): options.flexibleq = parser.flexibleq options.list_quality = parser.list_quality options.subtitle = parser.subtitle + options.silent_semi = parser.silent_semi options.username = parser.username options.password = parser.password options.thumbnail = parser.thumbnail From 468f36c62cc530ed8ecfcd71897ad721d97d7171 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 5 May 2016 12:34:05 +0200 Subject: [PATCH 3/8] main: move all-subtitles to the rest of subtitles agruments --- lib/svtplay_dl/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/svtplay_dl/__init__.py b/lib/svtplay_dl/__init__.py index 8c329ed..1b6d4e4 100644 --- a/lib/svtplay_dl/__init__.py +++ b/lib/svtplay_dl/__init__.py @@ -343,6 +343,8 @@ def main(): action="store_true", help="download only subtitle if its used with -S") parser.add_option("--require-subtitle", dest="require_subtitle", default=False, action="store_true", help="download only if a subtitle is available") + parser.add_option("--all-subtitles", dest="get_all_subtitles", default=False, action="store_true", + help="Download all available subtitles for the video") parser.add_option("-u", "--username", default=None, help="username") parser.add_option("-p", "--password", default=None, @@ -370,8 +372,6 @@ def main(): help="If two streams have the same quality, choose the one you prefer") parser.add_option("--remux", dest="remux", default=False, action="store_true", help="Remux from one container to mp4 using ffmpeg or avconv") - parser.add_option("--all-subtitles", dest="get_all_subtitles", default=False, action="store_true", - help="Download all available subtitles for the video") (options, args) = parser.parse_args() if not args: parser.print_help() From 2ce05e7800a311dbe3cdc68ad57c9c780e932238 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 5 May 2016 12:37:31 +0200 Subject: [PATCH 4/8] Add new agruments to pod file --- svtplay-dl.pod | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/svtplay-dl.pod b/svtplay-dl.pod index a5e677d..2c7cdb3 100644 --- a/svtplay-dl.pod +++ b/svtplay-dl.pod @@ -47,6 +47,10 @@ Enable support for live streams. (rtmp based ones) Be less verbose. +=head3 --silent-semi + +only show a message when the file is downloaded + =head3 --verbose -v Explain what is going on, including HTTP requests and other useful @@ -77,6 +81,10 @@ Download only subtitle if its used with -S. Download only if a subtitle is available +=head3 --all-subtitles + +Download all available subtitles for the video + =head3 --username=USERNAME -u USERNAME Username, if the service requires authentication. From 5c2342f6c0aaa0603b5d905c672acc14537a8775 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 5 May 2016 12:53:06 +0200 Subject: [PATCH 5/8] diff_man: detect extented regex for sed --- scripts/diff_man_help.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/diff_man_help.sh b/scripts/diff_man_help.sh index dda4779..047c60d 100644 --- a/scripts/diff_man_help.sh +++ b/scripts/diff_man_help.sh @@ -12,21 +12,29 @@ TMPDIR=$(mktemp -d svtplay-man-test-XXXXXX) } trap 'rm -rf "$TMPDIR"' EXIT TERM +if echo "" | sed -r "" > /dev/null 2>&1 ; then + extended_regexp="-r" +elif echo "" | sed -E "" > /dev/null 2>&1 ; then + extended_regexp="-E" +else + echo "Cant find extented regex" +fi + # FIXME: *Currently* we don't have any =head3 that doesn't # document an option. This is thus fragile to changes. -sed -nre 's/^=head3 //p' svtplay-dl.pod > $TMPDIR/options.man +sed $extended_regexp -ne 's/^=head3 //p' svtplay-dl.pod > $TMPDIR/options.man ./svtplay-dl --help | grep '^ *-' > $TMPDIR/options.help # --help specific filtering -sed -i -re 's/ .*//' $TMPDIR/options.help -sed -i -re 's/ excl.*//' $TMPDIR/options.help -sed -i -re 's/^ *//' $TMPDIR/options.help -sed -i -re 's/OUTPUT/filename/g' $TMPDIR/options.help +sed -i $extended_regexp -e 's/ .*//' $TMPDIR/options.help +sed -i $extended_regexp -e 's/ excl.*//' $TMPDIR/options.help +sed -i $extended_regexp -e 's/^ *//' $TMPDIR/options.help +sed -i $extended_regexp -e 's/OUTPUT/filename/g' $TMPDIR/options.help for file in $TMPDIR/options.*; do - sed -i -re 's/, / /' $file - sed -i -re 's/ / /' $file + sed -i $extended_regexp -e 's/, / /' $file + sed -i $extended_regexp -e 's/ / /' $file # Normalize order of --help -h vs -h --help # "--help -h" => "-h --help" From dc2fb3f87481dc366936f6b475b1c1d1245510cd Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 5 May 2016 14:01:03 +0200 Subject: [PATCH 6/8] makefile: fix a sed error --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6aca9a5..e057340 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ clean_releasedir: release: $(RELEASE_DIR) release-test set -e; cd $(RELEASE_DIR) && \ - sed -i -re 's/^(__version__ = ).*/\1"$(NEW_RELEASE)"/' lib/svtplay_dl/__init__.py;\ + sed -i -re 's/^\(__version__ = \).*/\1"$(NEW_RELEASE)"/' lib/svtplay_dl/__init__.py;\ git add Makefile lib/svtplay_dl/__init__.py; \ git commit -m "New release $(NEW_RELEASE)"; (cd $(RELEASE_DIR) && git format-patch --stdout HEAD^) | git am From c97cdb31a8deb76b3c1a1ab6fce2f50563d306f6 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 5 May 2016 14:01:56 +0200 Subject: [PATCH 7/8] Update makefile version number --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e057340..35c0b0b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: svtplay-dl release clean_releasedir $(RELEASE_DIR) # These variables describe the latest release: -VERSION = 1.0 +VERSION = 1.1 LATEST_RELEASE = $(VERSION) # If we build a new release, this is what it will be called: From c6abc2e6d976016660cde9edec2378cb91633bc8 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 5 May 2016 14:02:03 +0200 Subject: [PATCH 8/8] New release 1.1 --- lib/svtplay_dl/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svtplay_dl/__init__.py b/lib/svtplay_dl/__init__.py index 1b6d4e4..1fd1ffe 100644 --- a/lib/svtplay_dl/__init__.py +++ b/lib/svtplay_dl/__init__.py @@ -49,7 +49,7 @@ from svtplay_dl.service.viaplay import Viaplay from svtplay_dl.service.vimeo import Vimeo from svtplay_dl.service.youplay import Youplay -__version__ = "1.0" +__version__ = "1.1" sites = [ Aftonbladet,