summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-01-18 19:44:34 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-01-18 19:49:58 +0100
commit69b83475a898b511d4e26544f2d0b4a09940c3ea (patch)
treefb95c909879c5d6d8cb4b84581a387b07c00812e
parent0b91c6c444a83c8d8f93ae29882a485858c95c5f (diff)
downloadflask-mediabrowser-69b83475a898b511d4e26544f2d0b4a09940c3ea.tar.gz
flask-mediabrowser-69b83475a898b511d4e26544f2d0b4a09940c3ea.zip
remove superflous asset controller function.
if http-authentication is directed do an redirect to same page without authentication.
-rw-r--r--mediabrowser/__init__.py4
-rw-r--r--mediabrowser/templates/listdir.html8
-rw-r--r--mediabrowser/templates/watch.html23
3 files changed, 20 insertions, 15 deletions
diff --git a/mediabrowser/__init__.py b/mediabrowser/__init__.py
index 824d7d8..28241b4 100644
--- a/mediabrowser/__init__.py
+++ b/mediabrowser/__init__.py
@@ -148,10 +148,6 @@ def build(root_directory, cache):
process = ffmpeg.thumbnail(ospath, 852, 480)
return process.stdout
- @blueprint.route('/assets/<path:filename>')
- def assets(filename):
- return blueprint.send_static_file(filename)
-
@blueprint.route('/<path:path>/stream/<float:ss>_<float:t>')
def stream(ss, t, path):
path = os.path.normpath(path)
diff --git a/mediabrowser/templates/listdir.html b/mediabrowser/templates/listdir.html
index 024822d..27cfdc8 100644
--- a/mediabrowser/templates/listdir.html
+++ b/mediabrowser/templates/listdir.html
@@ -2,12 +2,12 @@
<html>
<head>
<title>Directory Browser - {{ path }}</title>
- <link rel="stylesheet" href="{{ url_for('mediabrowser.assets', filename='style.css') }}" />
+ <link rel="stylesheet" href="{{ url_for('mediabrowser.static', filename='style.css') }}" />
</head>
<body class="list">
{% if path != '.' %}
<div>
- <img src="{{ url_for('mediabrowser.assets', filename='parent.png') }}" />
+ <img src="{{ url_for('mediabrowser.static', filename='parent.png') }}" />
<a href="{{ url_for('mediabrowser.listdir', path=parent) }}">
Parent Directory
</a>
@@ -18,7 +18,7 @@
{% if file['type'] == 'file' %}
<div>
<video src="{{ url_for('mediabrowser.thumbnail_video', path=file['fullpath']) }}"
- poster="{{ url_for('mediabrowser.assets', filename='spinner.gif') }}"
+ poster="{{ url_for('mediabrowser.static', filename='spinner.gif') }}"
autoplay="" loop="true" width="100" height="60">
</video>
<a href="{{ url_for('mediabrowser.watch', path=file['fullpath']) }}">
@@ -29,7 +29,7 @@
{% if file['type'] == 'directory' %}
<div>
- <img src="{{ url_for('mediabrowser.assets', filename='directory.png') }}" />
+ <img src="{{ url_for('mediabrowser.static', filename='directory.png') }}" />
<a href="{{ file['link'] }}">
{{ file['filename'] }}
</a>
diff --git a/mediabrowser/templates/watch.html b/mediabrowser/templates/watch.html
index 808e372..db7ab6e 100644
--- a/mediabrowser/templates/watch.html
+++ b/mediabrowser/templates/watch.html
@@ -2,8 +2,8 @@
<html>
<head>
<title>Watch - {{ filename }}</title>
- <script src="{{url_for('mediabrowser.assets', filename='hls.min.js')}}"></script>
- <link rel="stylesheet" href="{{ url_for('mediabrowser.assets', filename='style.css') }}"/>
+ <script src="{{url_for('mediabrowser.static', filename='hls.js/hls.min.js')}}"></script>
+ <link rel="stylesheet" href="{{ url_for('mediabrowser.static', filename='style.css') }}"/>
</head>
<body class="watch">
<video controls id="video"></video>
@@ -11,21 +11,21 @@
<div id="infos">
<a href="{{ url_for('mediabrowser.m3u8', path=path) }}">
<div>
- <img src="{{ url_for('mediabrowser.assets', filename='playlist.png') }}"/>
+ <img src="{{ url_for('mediabrowser.static', filename='playlist.png') }}"/>
<br/>
HLS with transcoding
</div>
</a>
<a href="{{ url_for('mediabrowser.download_inline', path=path) }}">
<div>
- <img src="{{ url_for('mediabrowser.assets', filename='playlist.png') }}"/>
+ <img src="{{ url_for('mediabrowser.static', filename='playlist.png') }}"/>
<br/>
Inline
</div>
</a>
<a href="{{ url_for('mediabrowser.download', path=path) }}">
<div>
- <img src="{{ url_for('mediabrowser.assets', filename='playlist.png') }}"/>
+ <img src="{{ url_for('mediabrowser.static', filename='playlist.png') }}"/>
<br/>
Download
</div>
@@ -64,13 +64,22 @@
levelLoadingTimeOut: 20000,
fragLoadingTimeOut: 120000
};
+ video.setAttribute('poster',
+ "{{ url_for('mediabrowser.poster', path=path) }}");
var hls = new Hls(config);
+ hls.on(Hls.Events.MANIFEST_LOADED, function(event, data) {
+ // test if url contains authentication (http://user:pass@host/)
+ var authUrl = /(http?:\/\/)[^\/]*@([^\/]+\/.*)/.exec(data.url)
+ if (authUrl) {
+ // redirect to same page without authentication.
+ // hls.js fails otherwise in src/utils/url.js #buildAbsoluteURL()
+ window.location = window.location.href;
+ }
+ });
hls.loadSource("{{ url_for('mediabrowser.m3u8', path=path) }}");
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
video.play();
- video.setAttribute('poster',
- "{{ url_for('mediabrowser.poster', path=path) }}");
});
hls.on(Hls.Events.ERROR, function (event, data) {
if (data.fatal) {