From c99f4bd3d36933f5cda3ad489fffb93158d2522e Mon Sep 17 00:00:00 2001 From: gillouche Date: Wed, 2 Mar 2016 21:42:47 +0100 Subject: [PATCH 1/5] allows more possibilities for the match filter options --- README.md | 10 +++++++++- test/test_utils.py | 19 +++++++++++++++++++ youtube_dl/utils.py | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d66804a7a..d3e950869 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,15 @@ which means you can modify it, redistribute it or use it however you like. functionality is not available at the given service), but who also have a description, use --match-filter "like_count > 100 & - dislike_count 100 & dislike_count %s)(?P\s*\?)?\s* (?: (?P[0-9.]+(?:[kKmMgGtTpPeEzZyY]i?[Bb]?)?)| - (?P(?![0-9.])[a-z0-9A-Z]*) + (?P(?![0-9.])[a-z0-9A-Z\s_-]*) ) \s*$ ''' % '|'.join(map(re.escape, COMPARISON_OPERATORS.keys()))) From 9fe112c2226b14922dd471c44aff3203c8ac8df7 Mon Sep 17 00:00:00 2001 From: gillouche Date: Wed, 2 Mar 2016 22:38:55 +0100 Subject: [PATCH 2/5] prevents wrong matching results because of trailing spaces for the match-filter options --- test/test_utils.py | 4 +++- youtube_dl/utils.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index 33b496573..5e0754fe1 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -712,7 +712,9 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') self.assertTrue(match_str( 'playlist_title != some-playlist_name & playlist_title != some_playlist-name', {'playlist_title': 'some_playlist'})) - + self.assertFalse(match_str( + 'playlist_title != some playlist with space & playlist_title != foobar', + {'playlist_title': 'some playlist with space'})) def test_parse_dfxp_time_expr(self): self.assertEqual(parse_dfxp_time_expr(None), None) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index fd32d904d..128248a52 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2011,7 +2011,7 @@ def match_str(filter_str, dct): """ Filter a dictionary with a simple string syntax. Returns True (=passes filter) or false """ return all( - _match_one(filter_part, dct) for filter_part in filter_str.split('&')) + _match_one(filter_part.strip(), dct) for filter_part in filter_str.split('&')) def match_filter_func(filter_str): From 49abafd765bdd53bd51810b10145635e49d1efe0 Mon Sep 17 00:00:00 2001 From: Gilles Habran Date: Thu, 3 Mar 2016 09:21:23 +0100 Subject: [PATCH 3/5] adds almost all valid characters for a valid youtube playlist name to the match filter options --- README.md | 4 +++- test/test_utils.py | 15 +++++++++++++++ youtube_dl/utils.py | 8 +++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d3e950869..45d4c29ca 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,9 @@ which means you can modify it, redistribute it or use it however you like. be evaluated. For example, the youtube playlist 'Liked videos' will not be downloaded with the following filter : - --match-filter "playlist_title != Liked videos" + --match-filter "playlist_title != Liked videos". + Most valid characters for a valid youtube + playlist name in English can also be used. --no-playlist Download only the video, if the URL refers to a video and a playlist. --yes-playlist Download the playlist, if the URL refers to diff --git a/test/test_utils.py b/test/test_utils.py index 5e0754fe1..22597f415 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -715,6 +715,21 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') self.assertFalse(match_str( 'playlist_title != some playlist with space & playlist_title != foobar', {'playlist_title': 'some playlist with space'})) + self.assertFalse(match_str( + 'playlist_title != some playlist with space & playlist_title != foobar', + {'playlist_title': ' some playlist with space '})) + self.assertTrue(match_str( + 'playlist_title != some playlist with space & playlist_title != foobar', + {'playlist_title': ' some playlist with space but other name '})) + self.assertTrue(match_str( + "playlist_title = It's a playlist with quote", + {'playlist_title': "It's a playlist with quote"})) + self.assertTrue(match_str( + "playlist_title = playlist with {}[]/\()", + {'playlist_title': "playlist with {}[]/\()"})) + self.assertTrue(match_str( + "playlist_title = playlist with valid characters +~#^!?§:;.", + {'playlist_title': "playlist with valid characters +~#^!?§:;."})) def test_parse_dfxp_time_expr(self): self.assertEqual(parse_dfxp_time_expr(None), None) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 128248a52..517c4aee1 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1962,7 +1962,7 @@ def _match_one(filter_part, dct): \s*(?P%s)(?P\s*\?)?\s* (?: (?P[0-9.]+(?:[kKmMgGtTpPeEzZyY]i?[Bb]?)?)| - (?P(?![0-9.])[a-z0-9A-Z\s_-]*) + (?P(?![0-9.])[a-z0-9A-Z\.\'\(\)\{\}\[\]/\\\^\?:;~#!§+\s_-]*) ) \s*$ ''' % '|'.join(map(re.escape, COMPARISON_OPERATORS.keys()))) @@ -1973,7 +1973,7 @@ def _match_one(filter_part, dct): if m.group('op') not in ('=', '!='): raise ValueError( 'Operator %s does not support string values!' % m.group('op')) - comparison_value = m.group('strval') + comparison_value = m.group('strval').strip() else: try: comparison_value = int(m.group('intval')) @@ -1988,6 +1988,8 @@ def _match_one(filter_part, dct): actual_value = dct.get(m.group('key')) if actual_value is None: return m.group('none_inclusive') + if isinstance(actual_value, compat_basestring): + actual_value = actual_value.strip() return op(actual_value, comparison_value) UNARY_OPERATORS = { @@ -2011,7 +2013,7 @@ def match_str(filter_str, dct): """ Filter a dictionary with a simple string syntax. Returns True (=passes filter) or false """ return all( - _match_one(filter_part.strip(), dct) for filter_part in filter_str.split('&')) + _match_one(filter_part, dct) for filter_part in filter_str.split('&')) def match_filter_func(filter_str): From 799bd34ec1d57d7397d2350d09fb27afe19e782c Mon Sep 17 00:00:00 2001 From: Gilles Habran Date: Fri, 15 Apr 2016 15:51:21 +0200 Subject: [PATCH 4/5] markdown formatting --- README.md | 27 +++++++++------------------ docs/supportedsites.md | 7 +++++-- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 4a86d1623..7e03e0523 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,8 @@ which means you can modify it, redistribute it or use it however you like. repairs broken URLs, but emits an error if this is not possible instead of searching. --ignore-config Do not read configuration files. When given - in the global configuration file /etc - /youtube-dl.conf: Do not read the user + in the global configuration file + /etc/youtube-dl.conf: Do not read the user configuration in ~/.config/youtube- dl/config (%APPDATA%/youtube-dl/config.txt on Windows) @@ -146,17 +146,7 @@ which means you can modify it, redistribute it or use it however you like. functionality is not available at the given service), but who also have a description, use --match-filter "like_count > 100 & - dislike_count Date: Fri, 6 May 2016 08:44:26 +0200 Subject: [PATCH 5/5] supported sites --- docs/supportedsites.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index 9fb43671f..18a2a2fd2 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -700,6 +700,7 @@ - **Vessel** - **Vesti**: Вести.Ru - **Vevo** + - **VevoPlaylist** - **VGTV**: VGTV, BTTV, FTV, Aftenposten and Aftonbladet - **vh1.com** - **Vice** @@ -772,7 +773,7 @@ - **WSJ**: Wall Street Journal - **XBef** - **XboxClips** - - **XFileShare**: XFileShare based sites: GorillaVid.in, daclips.in, movpod.in, fastvideo.in, realvid.net, filehoot.com and vidto.me + - **XFileShare**: XFileShare based sites: DaClips, FileHoot, GorillaVid, MovPod, PowerWatch, Rapidvideo.ws, TheVideoBee, Vidto, Streamin.To - **XHamster** - **XHamsterEmbed** - **xiami:album**: 虾米音乐 - 专辑