From fd74adb42fee3b99ea1d0433cc0cb23ecf4059bf Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 3 Jun 2019 14:04:41 +0530 Subject: [PATCH 1/4] Prefer secure HTTPS by default --- spotdl/patcher.py | 3 +++ spotdl/youtube_tools.py | 1 + 2 files changed, 4 insertions(+) diff --git a/spotdl/patcher.py b/spotdl/patcher.py index d9e8762ad..a89fe15e3 100644 --- a/spotdl/patcher.py +++ b/spotdl/patcher.py @@ -43,3 +43,6 @@ def patch_getbestthumb(self): def patch_process_streams(self): backend_youtube_dl.YtdlPafy._old_process_streams = backend_youtube_dl.YtdlPafy._process_streams backend_youtube_dl.YtdlPafy._process_streams = _process_streams + + def patch_insecure_streams(self): + pafy.g.def_ydl_opts["prefer_insecure"] = False diff --git a/spotdl/youtube_tools.py b/spotdl/youtube_tools.py index 7c331caac..ff8fd762e 100644 --- a/spotdl/youtube_tools.py +++ b/spotdl/youtube_tools.py @@ -21,6 +21,7 @@ pafy_patcher = patcher.PatchPafy() pafy_patcher.patch_getbestthumb() pafy_patcher.patch_process_streams() + pafy_patcher.patch_insecure_streams() def set_api_key(): From 9f1f361dcbcb147f2dc4a7f0b77de7fa626d6fa7 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 3 Jun 2019 14:15:23 +0530 Subject: [PATCH 2/4] Add docs on what this is about --- spotdl/patcher.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spotdl/patcher.py b/spotdl/patcher.py index a89fe15e3..d52bacf6c 100644 --- a/spotdl/patcher.py +++ b/spotdl/patcher.py @@ -35,14 +35,21 @@ def _content_available(cls, url): class PatchPafy: + """ + These patches have not been released by pafy on PyPI yet but + are useful to us. + """ def patch_getbestthumb(self): + # https://github.com/mps-youtube/pafy/pull/211 pafy.backend_shared.BasePafy._bestthumb = None pafy.backend_shared.BasePafy._content_available = _content_available pafy.backend_shared.BasePafy.getbestthumb = _getbestthumb def patch_process_streams(self): + # https://github.com/mps-youtube/pafy/pull/230 backend_youtube_dl.YtdlPafy._old_process_streams = backend_youtube_dl.YtdlPafy._process_streams backend_youtube_dl.YtdlPafy._process_streams = _process_streams def patch_insecure_streams(self): + # https://github.com/mps-youtube/pafy/pull/235 pafy.g.def_ydl_opts["prefer_insecure"] = False From b6c5c885504c807a9c4f72c1fdc5bbd917c8be73 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 3 Jun 2019 14:15:35 +0530 Subject: [PATCH 3/4] Fix tests for now and rephrase comments for clarity --- test/test_spotify_tools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_spotify_tools.py b/test/test_spotify_tools.py index 4c9f51063..e0bc28d72 100644 --- a/test/test_spotify_tools.py +++ b/test/test_spotify_tools.py @@ -115,7 +115,7 @@ def test_write_playlist(tmpdir): assert tracks == expect_tracks -# XXX: Mock this test off if it fails in future +# XXX: Monkeypatch these tests if they fail in future class TestFetchAlbum: @pytest.fixture(scope="module") def album_fixture(self): @@ -131,7 +131,7 @@ def test_tracks(self, album_fixture): assert album_fixture["tracks"]["total"] == 15 -# XXX: Mock this test off if it fails in future +# XXX: Monkeypatch these tests if they fail in future class TestFetchAlbumsFromArtist: @pytest.fixture(scope="module") def albums_from_artist_fixture(self): @@ -141,7 +141,7 @@ def albums_from_artist_fixture(self): return albums def test_len(self, albums_from_artist_fixture): - assert len(albums_from_artist_fixture) == 52 + assert len(albums_from_artist_fixture) == 53 def test_zeroth_album_name(self, albums_from_artist_fixture): assert albums_from_artist_fixture[0]["name"] == "Revolution Radio" From f4cd70b60348590aba8ac1656191e064c04180f0 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 3 Jun 2019 14:18:31 +0530 Subject: [PATCH 4/4] Bump to v1.2.2 --- CHANGES.md | 4 ++++ spotdl/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4e23040ec..c0b41bdfd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - +## [1.2.2] - 2019-06-03 +### Fixed +- Patch bug in Pafy to prefer secure HTTPS ([@ritiek](https://github.com/ritiek)) (#558) + ## [1.2.1] - 2019-04-28 ### Fixed - Patch bug in Pafy when fetching audiostreams with latest youtube-dl ([@ritiek](https://github.com/ritiek)) (#539) diff --git a/spotdl/__init__.py b/spotdl/__init__.py index a955fdae1..bc86c944f 100644 --- a/spotdl/__init__.py +++ b/spotdl/__init__.py @@ -1 +1 @@ -__version__ = "1.2.1" +__version__ = "1.2.2"