Skip to content

Commit

Permalink
Merge pull request #558 from ritiek/pafy-prefer-secure-by-default
Browse files Browse the repository at this point in the history
Pafy prefer secure HTTPS by default
  • Loading branch information
ritiek authored Jun 5, 2019
2 parents b808265 + f4cd70b commit 5ca4317
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spotdl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
10 changes: 10 additions & 0 deletions spotdl/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +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
1 change: 1 addition & 0 deletions spotdl/youtube_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
6 changes: 3 additions & 3 deletions test/test_spotify_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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"
Expand Down

0 comments on commit 5ca4317

Please sign in to comment.