Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check python version and enable https where it's possible #2307

Merged
merged 22 commits into from
Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
import six

VARIOUS_ARTISTS_ID = '89ad4ac3-39f7-470e-963a-56509c546377'
BASE_URL = 'http://musicbrainz.org/'

if util.SNI_SUPPORTED:
BASE_URL = 'https://musicbrainz.org/'
else:
BASE_URL = 'http://musicbrainz.org/'

musicbrainzngs.set_useragent('beets', beets.__version__,
'http://beets.io/')
Expand Down
1 change: 1 addition & 0 deletions beets/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

MAX_FILENAME_LENGTH = 200
WINDOWS_MAGIC_PREFIX = u'\\\\?\\'
SNI_SUPPORTED = sys.version_info >= (2, 7, 9)


class HumanReadableException(Exception):
Expand Down
5 changes: 4 additions & 1 deletion beets/util/artresizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
IMAGEMAGICK = 2
WEBPROXY = 3

PROXY_URL = 'http://images.weserv.nl/'
if util.SNI_SUPPORTED:
PROXY_URL = 'https://images.weserv.nl/'
else:
PROXY_URL = 'http://images.weserv.nl/'

log = logging.getLogger('beets')

Expand Down
15 changes: 9 additions & 6 deletions beetsplug/fetchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,12 @@ def fetch_image(self, candidate, extra):
class CoverArtArchive(RemoteArtSource):
NAME = u"Cover Art Archive"

URL = 'http://coverartarchive.org/release/{mbid}/front'
GROUP_URL = 'http://coverartarchive.org/release-group/{mbid}/front'
if util.SNI_SUPPORTED:
URL = 'https://coverartarchive.org/release/{mbid}/front'
GROUP_URL = 'https://coverartarchive.org/release-group/{mbid}/front'
else:
URL = 'http://coverartarchive.org/release/{mbid}/front'
GROUP_URL = 'http://coverartarchive.org/release-group/{mbid}/front'

def get(self, album, extra):
"""Return the Cover Art Archive and Cover Art Archive release group URLs
Expand Down Expand Up @@ -394,8 +398,7 @@ def get(self, album, extra):
class FanartTV(RemoteArtSource):
"""Art from fanart.tv requested using their API"""
NAME = u"fanart.tv"

API_URL = 'http://webservice.fanart.tv/v3/'
API_URL = 'https://webservice.fanart.tv/v3/'
API_ALBUMS = API_URL + 'music/albums/'
PROJECT_KEY = '61a7d0ab4e67162b7a0c7c35915cd48e'

Expand Down Expand Up @@ -488,8 +491,8 @@ def get(self, album, extra):

class Wikipedia(RemoteArtSource):
NAME = u"Wikipedia (queried through DBpedia)"
DBPEDIA_URL = 'http://dbpedia.org/sparql'
WIKIPEDIA_URL = 'http://en.wikipedia.org/w/api.php'
DBPEDIA_URL = 'https://dbpedia.org/sparql'
WIKIPEDIA_URL = 'https://en.wikipedia.org/w/api.php'
SPARQL_QUERY = u'''PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX owl: <http://dbpedia.org/ontology/>
Expand Down
2 changes: 1 addition & 1 deletion beetsplug/lastimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from beets import plugins
from beets.dbcore import types

API_URL = 'http://ws.audioscrobbler.com/2.0/'
API_URL = 'https://ws.audioscrobbler.com/2.0/'


class LastImportPlugin(plugins.BeetsPlugin):
Expand Down
2 changes: 1 addition & 1 deletion beetsplug/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def get_bing_access_token(self):
params = {
'client_id': 'beets',
'client_secret': self.config['bing_client_secret'],
'scope': 'http://api.microsofttranslator.com',
'scope': "https://api.microsofttranslator.com",
'grant_type': 'client_credentials',
}

Expand Down
11 changes: 8 additions & 3 deletions test/test_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CombinedTest(FetchImageHelper, UseThePlugin):
.format(ASIN)
AAO_URL = 'http://www.albumart.org/index_detail.php?asin={0}' \
.format(ASIN)
CAA_URL = 'http://coverartarchive.org/release/{0}/front' \
CAA_URL = 'coverartarchive.org/release/{0}/front' \
.format(MBID)

def setUp(self):
Expand Down Expand Up @@ -202,12 +202,17 @@ def test_main_interface_falls_back_to_aao(self):
self.assertEqual(responses.calls[-1].request.url, self.AAO_URL)

def test_main_interface_uses_caa_when_mbid_available(self):
self.mock_response(self.CAA_URL)
self.mock_response("http://" + self.CAA_URL)
self.mock_response("https://" + self.CAA_URL)
album = _common.Bag(mb_albumid=self.MBID, asin=self.ASIN)
candidate = self.plugin.art_for_album(album, None)
self.assertIsNotNone(candidate)
self.assertEqual(len(responses.calls), 1)
self.assertEqual(responses.calls[0].request.url, self.CAA_URL)
if util.SNI_SUPPORTED:
url = "https://" + self.CAA_URL
else:
url = "http://" + self.CAA_URL
self.assertEqual(responses.calls[0].request.url, url)

def test_local_only_does_not_access_network(self):
album = _common.Bag(mb_albumid=self.MBID, asin=self.ASIN)
Expand Down