Skip to content

Commit

Permalink
Merge branch 'release-0.41.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tilboerner committed Feb 7, 2018
2 parents 59f2424 + d9eff82 commit 911b757
Show file tree
Hide file tree
Showing 13 changed files with 722 additions and 973 deletions.
21 changes: 14 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
#

language: python
sudo: False
cache:
- pip

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev"
- "pypy"
- "pypy3"

Expand All @@ -31,12 +36,6 @@ matrix:
env: "CHERRYPY_VERSION='>=3.5,<3.6'"
- python: "3.3"
env: "CHERRYPY_VERSION='>=3.2,<3.3'"
- python: "3.3"
env: "CHERRYPY_VERSION='>=3.3,<3.4'"
- python: "3.3"
env: "CHERRYPY_VERSION='>=3.4,<3.5'"
- python: "3.3"
env: "CHERRYPY_VERSION='>=3.5,<3.6'"
- python: "3.4"
env: "CHERRYPY_VERSION='>=4.0,<5.0'"
- python: "3.4"
Expand All @@ -49,15 +48,23 @@ matrix:
env: "CHERRYPY_VERSION='>=8.0,<9.0'"
- python: "3.4"
env: "CHERRYPY_VERSION='>=9.0,<10.0'"
- python: "3.4"
env: "CHERRYPY_VERSION='>=10.0,<11.0'"
- python: "3.4"
env: "CHERRYPY_VERSION='>=11.0,<12.0'"
- python: "3.4"
env: "CHERRYPY_VERSION='>=12.0,<13.0'"
allow_failures:
- env: "CHERRYPY_VERSION='>=3.2,<3.3'"
- python: "3.7-dev"
- env: "CHERRYPY_VERSION='>=3.3,<3.4'"
- env: "CHERRYPY_VERSION='>=3.4,<3.5'"
- env: "CHERRYPY_VERSION='>=3.5,<3.6'"
fast_finish: true

# command to install dependencies
install:
- "pip install --upgrade setuptools"
- "pip install --upgrade six"
- "pip install cherrypy${CHERRYPY_VERSION} --no-use-wheel"
- "pip install coveralls pyyaml"
- "if [[ $TRAVIS_PYTHON_VERSION = 2.6 ]]; then pip install unittest2; fi"
Expand Down
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
---------

0.41.2 (2018-02-07)
- FIXED: Make jPlayer work again in master branch (merge 0.41.1 into master)
- FIXED: '--setup' now works for CherryPy 12 and upwards (thanks to TangoSierraAlfaVI)
- FIXED: UnicodeError when transcoding non-ASCII URLs (thanks to evetsso)
- IMPROVEMENT: Added Bandcamp album cover fetching (thanks to its-wednesday)

0.41.1 (2017-10-10)
- FIXED: reverted jPlayer update, because it broke everything

Expand Down
11 changes: 6 additions & 5 deletions cherrymusicserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#python 2.6+ backward compability
from __future__ import unicode_literals

VERSION = "0.41.1"
VERSION = "0.41.2"
__version__ = VERSION
DESCRIPTION = "an mp3 server for your browser"
LONG_DESCRIPTION = """CherryMusic is a music streaming
Expand Down Expand Up @@ -466,10 +466,11 @@ def start_server(self, httphandler):
basedirpath = codecs.encode(basedirpath, 'utf-8')
scriptname = codecs.encode(config['server.rootpath'], 'utf-8')
else:
# fix cherrypy unicode issue (only for Python3)
# see patch to cherrypy.lib.static.serve_file way above and
# https://bitbucket.org/cherrypy/cherrypy/issue/1148/wrong-encoding-for-urls-containing-utf-8
basedirpath = codecs.decode(codecs.encode(basedirpath, 'utf-8'), 'latin-1')
if needs_serve_file_utf8_fix:
# fix cherrypy unicode issue (only for Python3)
# see patch to cherrypy.lib.static.serve_file way above and
# https://bitbucket.org/cherrypy/cherrypy/issue/1148/wrong-encoding-for-urls-containing-utf-8
basedirpath = codecs.decode(codecs.encode(basedirpath, 'utf-8'), 'latin-1')
scriptname = config['server.rootpath']
cherrypy.tree.mount(
httphandler, scriptname,
Expand Down
9 changes: 8 additions & 1 deletion cherrymusicserver/albumartfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,20 @@ class AlbumArtFetcher:
'url': "http://www.amazon.com/s/?field-keywords=",
'regexes': [
'<img[^>]+?alt="Product Details"[^>]+?src="([^"]+)"',
'<img[^>]+?src="([^"]+)"[^>]+?alt="Product Details"'],
'<img[^>]+?src="([^"]+)"[^>]+?alt="Product Details"',
'<img[^>]+?src="([^"]+)"[^>]+?class="s-access-image',
'<img[^>]+?src="([^"]+)"[^>]+?data-search-image',
],
},
'bestbuy.com': {
'url': 'http://www.bestbuy.com/site/searchpage.jsp?_dyncharset=UTF-8&id=pcat17071&st=',
'regexes': ['<div class="thumb".+?<img.+?src="([^"]+)"'],
'user_agent': 'curl/7.52.1',
},
'bandcamp': {
'url': "https://bandcamp.com/search?q=",
'regexes': ['<div class="art".+?<img src="([^"]+)"']
}
# buy.com is now rakuten.com
# with a new search API that nobody bothered to figure out yet
# 'buy.com': {
Expand Down
1 change: 0 additions & 1 deletion cherrymusicserver/browsersetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,5 @@ def configureAndStartCherryPy(port):
'''.format(port=port)))

cherrypy.lib.caching.expires(0)
cherrypy.engine.timeout_monitor.frequency = 1
cherrypy.engine.start()
cherrypy.engine.block()
6 changes: 4 additions & 2 deletions cherrymusicserver/httphandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def trans(self, newformat, *path, **params):
path = os.path.sep.join(path)
if sys.version_info < (3, 0): # workaround for #327 (cherrypy issue)
path = path.decode('utf-8') # make it work with non-ascii
else:
elif cherry.needs_serve_file_utf8_fix:
path = codecs.decode(codecs.encode(path, 'latin1'), 'utf-8')
fullpath = os.path.join(cherry.config['media.basedir'], path)

Expand Down Expand Up @@ -654,7 +654,9 @@ def api_showplaylists(self, sortby="created", filterby=''):
return playlists

def api_logout(self):
cherrypy.lib.sessions.expire()
cherrypy.session['username'] = None
cherrypy.session['userid'] = None
cherrypy.session['admin'] = None
api_logout.no_auth = True

def api_downloadpls(self, plid, hostaddr):
Expand Down
41 changes: 28 additions & 13 deletions cherrymusicserver/test/test_httphandler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# CherryMusic - a standalone music server
# Copyright (c) 2012 - 2014 Tom Wallroth & Tilman Boerner
Expand Down Expand Up @@ -44,7 +45,6 @@
from cherrymusicserver import service
from cherrymusicserver.cherrymodel import CherryModel, MusicEntry

from cherrymusicserver import log

class MockAction(Exception):
pass
Expand Down Expand Up @@ -321,19 +321,34 @@ def test_api_userchangepassword(self):
session is used to authenticate the http request."""
self.assertRaises(AttributeError, self.http.api, 'userchangepassword')

def test_trans(self):
import os
config = {'media.basedir': 'BASEDIR', 'media.transcode': True}
with mock_auth():
with patch('cherrymusicserver.httphandler.cherry.config', config):
with patch('cherrymusicserver.httphandler.cherrypy'):
with patch('cherrymusicserver.httphandler.audiotranscode.AudioTranscode') as transcoder:
transcoder.return_value = transcoder
expectPath = os.path.join(config['media.basedir'], 'path')

httphandler.HTTPHandler(config).trans('newformat', 'path', bitrate=111)

transcoder.transcode_stream.assert_called_with(expectPath, 'newformat', bitrate=111, starttime=0)
def test_trans():
import sys
if sys.version_info < (3, 0):
test_paths = ['path', ('p\xc3\xb6th', u'pöth')]
elif cherry.needs_serve_file_utf8_fix:
test_paths = ['path',
('pöth'.encode('utf-8').decode('latin-1'), 'pöth')]
else:
test_paths = ['path', 'pöth']
for path in test_paths:
yield check_trans, path


def check_trans(path):
import os
path, expectPath = (path, path) if isinstance(path, str) else path
config = {'media.basedir': 'BASEDIR', 'media.transcode': True}
with mock_auth():
with patch('cherrymusicserver.httphandler.cherry.config', config):
with patch('cherrymusicserver.httphandler.cherrypy'):
with patch('cherrymusicserver.httphandler.audiotranscode.AudioTranscode') as transcoder:
transcoder.return_value = transcoder
expectPath = os.path.join(config['media.basedir'], expectPath)

httphandler.HTTPHandler(config).trans('newformat', path, bitrate=111)

transcoder.transcode_stream.assert_called_with(expectPath, 'newformat', bitrate=111, starttime=0)


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 911b757

Please sign in to comment.