From ca9cd290c7962908c67f344ce97b9092369df7f0 Mon Sep 17 00:00:00 2001 From: Naglis Jonaitis Date: Sun, 31 Aug 2014 23:11:52 +0300 Subject: [PATCH 1/2] [tudou] Fix #3643 - filter non-number qualities --- youtube_dl/extractor/tudou.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/tudou.py b/youtube_dl/extractor/tudou.py index 7a3891b89..96e0732bd 100644 --- a/youtube_dl/extractor/tudou.py +++ b/youtube_dl/extractor/tudou.py @@ -57,7 +57,8 @@ class TudouIE(InfoExtractor): segments = json.loads(segs_json) # It looks like the keys are the arguments that have to be passed as # the hd field in the request url, we pick the higher - quality = sorted(segments.keys())[-1] + # Also, filter non-number qualities (see issue #3643). + quality = sorted(filter(lambda k: k.isdigit(), segments.keys()))[-1] parts = segments[quality] result = [] len_parts = len(parts) From f931e2595936776380de5df9288a11c04337d780 Mon Sep 17 00:00:00 2001 From: Naglis Jonaitis Date: Sun, 31 Aug 2014 23:14:35 +0300 Subject: [PATCH 2/2] [tudou] Sort qualities by numeric value --- youtube_dl/extractor/tudou.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/tudou.py b/youtube_dl/extractor/tudou.py index 96e0732bd..23816599c 100644 --- a/youtube_dl/extractor/tudou.py +++ b/youtube_dl/extractor/tudou.py @@ -58,7 +58,8 @@ class TudouIE(InfoExtractor): # It looks like the keys are the arguments that have to be passed as # the hd field in the request url, we pick the higher # Also, filter non-number qualities (see issue #3643). - quality = sorted(filter(lambda k: k.isdigit(), segments.keys()))[-1] + quality = sorted(filter(lambda k: k.isdigit(), segments.keys()), + key=lambda k: int(k))[-1] parts = segments[quality] result = [] len_parts = len(parts)