A feature-rich command-line audio/video downloader
Merge branch 'paged-lists'
Philipp Hagemeister65697b3bf3bf
diff --cc test/test_utils.pyindex a17483ada8,349c1107f4..c68e0e9684--- a/test/test_utils.py+++ b/test/test_utils.py@@@ -16,9 -16,9 +16,10 @@@ from youtube_dl.utils importDateRange,encodeFilename,find_xpath_attr,+ fix_xml_ampersands,get_meta_content,orderedSet,+ PagedList,parse_duration,sanitize_filename,shell_quote,@@@ -201,18 -201,26 +202,39 @@@ class TestUtil(unittest.TestCase)self.assertEqual(parse_duration('9:12:43'), 33163)self.assertEqual(parse_duration('x:y'), None)+ def test_fix_xml_ampersands(self):+ self.assertEqual(+ fix_xml_ampersands('"&x=y&z=a'), '"&x=y&z=a')+ self.assertEqual(+ fix_xml_ampersands('"&x=y&wrong;&z=a'),+ '"&x=y&wrong;&z=a')+ self.assertEqual(+ fix_xml_ampersands('&'><"'),+ '&'><"')+ self.assertEqual(+ fix_xml_ampersands('Ӓ᪼'), 'Ӓ᪼')+ self.assertEqual(fix_xml_ampersands('&#&#'), '&#&#')++ def test_paged_list(self):+ def testPL(size, pagesize, sliceargs, expected):+ def get_page(pagenum):+ firstid = pagenum * pagesize+ upto = min(size, pagenum * pagesize + pagesize)+ for i in range(firstid, upto):+ yield i++ pl = PagedList(get_page, pagesize)+ got = pl.getslice(*sliceargs)+ self.assertEqual(got, expected)++ testPL(5, 2, (), [0, 1, 2, 3, 4])+ testPL(5, 2, (1,), [1, 2, 3, 4])+ testPL(5, 2, (2,), [2, 3, 4])+ testPL(5, 2, (4,), [4])+ testPL(5, 2, (0, 3), [0, 1, 2])+ testPL(5, 2, (1, 4), [1, 2, 3])+ testPL(5, 2, (2, 99), [2, 3, 4])+ testPL(5, 2, (20, 99), [])+if __name__ == '__main__':unittest.main()diff --cc youtube_dl/extractor/youtube.pyindex 870b7c4cab,dd1a58f3fc..57b8fdff72--- a/youtube_dl/extractor/youtube.py+++ b/youtube_dl/extractor/youtube.py@@@ -27,7 -27,7 +27,8 @@@ from ..utils importget_element_by_id,get_element_by_attribute,ExtractorError,+ int_or_none,+ PagedList,RegexNotFoundError,unescapeHTML,unified_strdate,