mirror of
https://github.com/beetbox/beets.git
synced 2026-02-20 06:14:22 +01:00
use urllib from six.moves
This commit is contained in:
parent
1f8fe0f9a6
commit
4649226b9b
8 changed files with 19 additions and 21 deletions
|
|
@ -20,7 +20,7 @@ from __future__ import division, absolute_import, print_function
|
|||
import musicbrainzngs
|
||||
import re
|
||||
import traceback
|
||||
from urlparse import urljoin
|
||||
from six.moves.urllib.parse import urljoin
|
||||
|
||||
from beets import logging
|
||||
import beets.autotag.hooks
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@ public resizing proxy if neither is available.
|
|||
"""
|
||||
from __future__ import division, absolute_import, print_function
|
||||
|
||||
import urllib
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from six.moves.urllib.parse import urlencode
|
||||
from beets import logging
|
||||
from beets import util
|
||||
|
||||
|
|
@ -41,7 +40,7 @@ def resize_url(url, maxwidth):
|
|||
"""Return a proxied image URL that resizes the original image to
|
||||
maxwidth (preserving aspect ratio).
|
||||
"""
|
||||
return '{0}?{1}'.format(PROXY_URL, urllib.urlencode({
|
||||
return '{0}?{1}'.format(PROXY_URL, urlencode({
|
||||
'url': url.replace('http://', ''),
|
||||
'w': bytes(maxwidth),
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import time
|
|||
from six.moves import _thread
|
||||
import os
|
||||
import copy
|
||||
import urllib
|
||||
from six.moves import urllib
|
||||
from beets import ui
|
||||
|
||||
import gi
|
||||
|
|
@ -130,7 +130,7 @@ class GstPlayer(object):
|
|||
self.player.set_state(Gst.State.NULL)
|
||||
if isinstance(path, unicode):
|
||||
path = path.encode('utf8')
|
||||
uri = 'file://' + urllib.quote(path)
|
||||
uri = 'file://' + urllib.parse.quote(path)
|
||||
self.player.set_property("uri", uri)
|
||||
self.player.set_state(Gst.State.PLAYING)
|
||||
self.playing = True
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ from __future__ import division, absolute_import, print_function
|
|||
|
||||
from beets import config
|
||||
from beets.plugins import BeetsPlugin
|
||||
from urllib import urlencode
|
||||
from urlparse import urljoin, parse_qs, urlsplit, urlunsplit
|
||||
from six.moves.urllib.parse import urlencode
|
||||
from six.moves.urllib.parse import urljoin, parse_qs, urlsplit, urlunsplit
|
||||
import hashlib
|
||||
import requests
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import json
|
|||
import re
|
||||
import requests
|
||||
import unicodedata
|
||||
import urllib
|
||||
import warnings
|
||||
from six.moves.html_parser import HTMLParseError
|
||||
from six.moves import urllib
|
||||
|
||||
try:
|
||||
from bs4 import SoupStrainer, BeautifulSoup
|
||||
|
|
@ -181,7 +181,7 @@ class Backend(object):
|
|||
for char, repl in URL_CHARACTERS.items():
|
||||
s = s.replace(char, repl)
|
||||
s = s.encode('utf8', 'ignore')
|
||||
return urllib.quote(s)
|
||||
return urllib.parse.quote(s)
|
||||
|
||||
def build_url(self, artist, title):
|
||||
return self.URL_PATTERN % (self._encode(artist.title()),
|
||||
|
|
@ -256,7 +256,7 @@ class Genius(Backend):
|
|||
def search_genius(self, artist, title):
|
||||
query = u"%s %s" % (artist, title)
|
||||
url = u'https://api.genius.com/search?q=%s' \
|
||||
% (urllib.quote(query.encode('utf8')))
|
||||
% (urllib.parse.quote(query.encode('utf8')))
|
||||
|
||||
self._log.debug(u'genius: requesting search {}', url)
|
||||
try:
|
||||
|
|
@ -542,9 +542,9 @@ class Google(Backend):
|
|||
query = u"%s %s" % (artist, title)
|
||||
url = u'https://www.googleapis.com/customsearch/v1?key=%s&cx=%s&q=%s' \
|
||||
% (self.api_key, self.engine_id,
|
||||
urllib.quote(query.encode('utf8')))
|
||||
urllib.parse.quote(query.encode('utf8')))
|
||||
|
||||
data = urllib.urlopen(url)
|
||||
data = urllib.request.urlopen(url)
|
||||
data = json.load(data)
|
||||
if 'error' in data:
|
||||
reason = data['error']['errors'][0]['reason']
|
||||
|
|
@ -643,7 +643,7 @@ class LyricsPlugin(plugins.BeetsPlugin):
|
|||
oauth_url = 'https://datamarket.accesscontrol.windows.net/v2/OAuth2-13'
|
||||
oauth_token = json.loads(requests.post(
|
||||
oauth_url,
|
||||
data=urllib.urlencode(params)).content)
|
||||
data=urllib.parse.urlencode(params)).content)
|
||||
if 'access_token' in oauth_token:
|
||||
return "Bearer " + oauth_token['access_token']
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import os
|
|||
import shutil
|
||||
import tempfile
|
||||
import plistlib
|
||||
import urllib
|
||||
from urlparse import urlparse
|
||||
|
||||
from six.moves.urllib.parse import urlparse, unquote
|
||||
from time import mktime
|
||||
|
||||
from beets import util
|
||||
|
|
@ -57,7 +57,7 @@ def _norm_itunes_path(path):
|
|||
# E.g., '\\G:\\Music\\bar' needs to be stripped to 'G:\\Music\\bar'
|
||||
|
||||
return util.bytestring_path(os.path.normpath(
|
||||
urllib.unquote(urlparse(path).path)).lstrip('\\')).lower()
|
||||
unquote(urlparse(path).path)).lstrip('\\')).lower()
|
||||
|
||||
|
||||
class Itunes(MetaSource):
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@ Put something like the following in your config.yaml to configure:
|
|||
from __future__ import division, absolute_import, print_function
|
||||
|
||||
import requests
|
||||
from urlparse import urljoin
|
||||
from urllib import urlencode
|
||||
import xml.etree.ElementTree as ET
|
||||
from six.moves.urllib.parse import urljoin, urlencode
|
||||
from beets import config
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from beets import config
|
|||
from beets.library import Item
|
||||
from beetsplug import spotify
|
||||
from test.helper import TestHelper
|
||||
import urlparse
|
||||
from six.moves.urllib.parse import parse_qs, urlparse
|
||||
|
||||
|
||||
class ArgumentsMock(object):
|
||||
|
|
@ -25,7 +25,7 @@ class ArgumentsMock(object):
|
|||
|
||||
def _params(url):
|
||||
"""Get the query parameters from a URL."""
|
||||
return urlparse.parse_qs(urlparse.urlparse(url).query)
|
||||
return parse_qs(urlparse(url).query)
|
||||
|
||||
|
||||
class SpotifyPluginTest(_common.TestCase, TestHelper):
|
||||
|
|
|
|||
Loading…
Reference in a new issue