Initial Commit
This commit is contained in:
commit
30c3419023
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
LICENSE*
|
||||
README*
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
docker-compose.yml
|
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@ -0,0 +1,31 @@
|
||||
FROM ubuntu:20.04
|
||||
|
||||
LABEL maintainer="Dehaeze Thomas <dehaeze.thomas@gmail.com>"
|
||||
|
||||
ENV \
|
||||
QOBUZ_NAME="" \
|
||||
QOBUZ_PASS="" \
|
||||
PUID="" \
|
||||
PGID=""
|
||||
|
||||
RUN \
|
||||
groupadd -g 1000 appuser && \
|
||||
useradd -r -u 1000 -g appuser appuser
|
||||
|
||||
|
||||
RUN \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
python3.4 \
|
||||
python3-pip
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN pip3 install --upgrade qobuz-dl CherryPy
|
||||
|
||||
COPY index.html index.html
|
||||
COPY main.py main.py
|
||||
ADD public public
|
||||
|
||||
CMD [ "python3", "main.py"]
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Muninn
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
10
docker-compose.yml.example
Normal file
10
docker-compose.yml.example
Normal file
@ -0,0 +1,10 @@
|
||||
version: '3'
|
||||
services:
|
||||
qobuz:
|
||||
image: docker-qobuz
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
- QOBUZNAME=name@gmail.com
|
||||
- QOBUZPASS=password123
|
||||
restart: unless-stopped
|
16
index.html
Normal file
16
index.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href="static/style.css" rel="stylesheet">
|
||||
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
|
||||
<script type="text/javascript" src="static/script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="form">
|
||||
<input type="text" value="" name="url"/>
|
||||
<button id="download">Download</button>
|
||||
</div>
|
||||
<div id="logoutput">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
58
main.py
Normal file
58
main.py
Normal file
@ -0,0 +1,58 @@
|
||||
import os, os.path
|
||||
import logging
|
||||
from io import StringIO
|
||||
import cherrypy
|
||||
from qobuz_dl.core import QobuzDL
|
||||
|
||||
email = os.environ['QOBUZNAME']
|
||||
password = os.environ['QOBUZPASS']
|
||||
|
||||
log_stream = StringIO()
|
||||
log_handler = logging.StreamHandler(log_stream)
|
||||
logger = logging.getLogger('qobuz_dl')
|
||||
logger.setLevel(logging.INFO)
|
||||
for handler in logger.handlers:
|
||||
logger.removeHandler(handler)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
|
||||
qobuz = QobuzDL(quality=7, directory='/downloads')
|
||||
qobuz.get_tokens() # get 'app_id' and 'secrets' attrs
|
||||
qobuz.initialize_client(email, password, qobuz.app_id, qobuz.secrets)
|
||||
|
||||
class Stringdownload(object):
|
||||
@cherrypy.expose
|
||||
def index(self):
|
||||
return open('index.html')
|
||||
|
||||
@cherrypy.expose
|
||||
class StringdownloadWebService(object):
|
||||
|
||||
@cherrypy.tools.accept(media='text/plain')
|
||||
def GET(self):
|
||||
return cherrypy.session['mystring']
|
||||
|
||||
def POST(self, url=''):
|
||||
log_stream.truncate(0)
|
||||
qobuz.handle_url(url)
|
||||
return log_stream.getvalue()
|
||||
|
||||
if __name__ == '__main__':
|
||||
conf = {
|
||||
'/': {
|
||||
'tools.sessions.on': True,
|
||||
'tools.staticdir.root': os.path.abspath(os.getcwd())
|
||||
},
|
||||
'/download': {
|
||||
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
|
||||
'tools.response_headers.on': True,
|
||||
'tools.response_headers.headers': [('Content-Type', 'text/plain')],
|
||||
},
|
||||
'/static': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': 'public'
|
||||
}
|
||||
}
|
||||
webapp = Stringdownload()
|
||||
webapp.download = StringdownloadWebService()
|
||||
cherrypy.quickstart(webapp, '/', conf)
|
15
public/script.js
Normal file
15
public/script.js
Normal file
@ -0,0 +1,15 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#download").click(function(e) {
|
||||
dl_button = $(this);
|
||||
dl_button.html('Downloading...');
|
||||
$("#logoutput").html('Loading...');
|
||||
|
||||
$.post("/download", {"url": $("input[name='url']").val()})
|
||||
.done(function(string) {
|
||||
dl_button.html('Download');
|
||||
$("#logoutput").html(string);
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
14
public/style.css
Normal file
14
public/style.css
Normal file
@ -0,0 +1,14 @@
|
||||
input {
|
||||
width: 25em;
|
||||
}
|
||||
|
||||
#form {
|
||||
text-align: center;
|
||||
margin: 2em;
|
||||
}
|
||||
|
||||
#logoutput {
|
||||
margin: 2em;
|
||||
white-space: pre-wrap;
|
||||
font-family: monospace;
|
||||
}
|
Loading…
Reference in New Issue
Block a user