From d1e065d9f6d606cd7b1131f88a2b7c0307ecbd99 Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 21 Feb 2019 12:57:58 -0500 Subject: [PATCH] quoting and unquoting url paths --- musik.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/musik.py b/musik.py index 33e241b..422757a 100755 --- a/musik.py +++ b/musik.py @@ -12,7 +12,7 @@ from flask import Flask, Response, render_template, send_file, url_for from flask_restful import reqparse, abort, Api, Resource import mutagen -MUSIC_DIR = "/mnt/music/Music" +MUSIC_DIR = "/home/iou1name/music/Music" MUSIC_EXT = ['flac', 'mp3', 'wav', 'm4a'] FFMPEG_CMD = [ 'ffmpeg', '-y', @@ -127,14 +127,14 @@ class Selection(Resource): found.pop('filepath') found['streampath'] = url_for( 'stream', - artist=track.artist, - album=track.album, - track=track.title) + artist=parse.quote(track.artist, safe=''), + album=parse.quote(track.album, safe=''), + track=parse.quote(track.title, safe='')) found['coverart'] = url_for( 'coverart', - artist=track.artist, - album=track.album, - track=track.title) + artist=parse.quote(track.artist, safe=''), + album=parse.quote(track.album, safe=''), + track=parse.quote(track.title, safe='')) return found elif args.get('album'): @@ -186,6 +186,7 @@ api.init_app(app) @app.route('/stream///') def stream(artist, album, track): """View for the raw audio file.""" + artist, album, track = map(parse.unquote, (artist, album, track)) for t in tracks: if (t.artist == artist and t.album == album and @@ -208,6 +209,7 @@ def stream(artist, album, track): @app.route('/coverart///') def coverart(artist, album, track): """View for the raw audio file.""" + artist, album, track = map(parse.unquote, (artist, album, track)) for t in tracks: if (t.artist == artist and t.album == album and