diff --git a/chrome-extension/background.js b/chrome-extension/background.js index 799d99d..3359ac7 100644 --- a/chrome-extension/background.js +++ b/chrome-extension/background.js @@ -25,7 +25,7 @@ function playUrl(url, pause) { } if (opts.maxheight) { opts.mpv_args.splice(0, 0, - `--ytdl-format=bestvideo[height<=?${opts.maxheight}]+bestaudio/best`); + `--ytdl-format=best[height<=${opts.maxheight}]/bestvideo[height<=?${opts.maxheight}]+bestaudio/best`); } const query = (`?play_url=` + encodeURIComponent(url) + [''].concat( opts.mpv_args.map(encodeURIComponent)).join('&mpv_args=')); @@ -58,8 +58,14 @@ chrome.contextMenus.onClicked.addListener(function(info, tab) { // console.log("item " + info.menuItemId + " was clicked"); // console.log("info: " + JSON.stringify(info)); // console.log("tab: " + JSON.stringify(tab)); - - playUrl(info["linkUrl"] || info["srcUrl"]|| info["pageUrl"], true); + + let url = info["linkUrl"] || info["srcUrl"]|| info["pageUrl"]; + + if (url !== undefined && url !== null) { + playUrl(url.replace("blob:", ""), true); + } else { + console.error("[play-with-mpv]: Failed to retrieve url from ifo", info); + } }); chrome.commands.onCommand.addListener(function(command) { diff --git a/play_with_mpv.py b/play_with_mpv.py index b03ee9e..e729334 100755 --- a/play_with_mpv.py +++ b/play_with_mpv.py @@ -100,7 +100,7 @@ def missing_bin(bin): def start(): parser = argparse.ArgumentParser(description='Plays MPV when instructed to by a browser extension.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--port', type=int, default=7531, help='The port to listen on.') - parser.add_argument('--public', action='store_true', help='Accept traffic from other comuters.') + parser.add_argument('--public', action='store_true', help='Accept traffic from other computers.') args = parser.parse_args() hostname = '0.0.0.0' if args.public else 'localhost' httpd = BaseHTTPServer.HTTPServer((hostname, args.port), Handler)