summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2020-04-03 01:44:42 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2020-04-03 01:44:42 +0000
commitb4e5866a45289c2192ddf66bff582aa9f7765699 (patch)
tree5e9b5923fa62c763705b90a25cbfdef2a85d6dca
parentUpdating. (diff)
downloadyoutube-dl-b4e5866a45289c2192ddf66bff582aa9f7765699.tar.xz
youtube-dl-b4e5866a45289c2192ddf66bff582aa9f7765699.zip
Updating.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rwxr-xr-xdownload.py53
-rw-r--r--html/download.html35
2 files changed, 69 insertions, 19 deletions
diff --git a/download.py b/download.py
index f085411..37f6f1f 100755
--- a/download.py
+++ b/download.py
@@ -36,34 +36,73 @@ if __name__ == '__main__':
form = FieldStorage()
if form.getvalue('url'):
+ Person = form.getvalue('person')
File = form.getvalue('file')
URL = form.getvalue('url')
Directory = str(form.getvalue('directory'))
Date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+ if not Person:
+ Person = '/'
+
+ print('Content-Type: text/html\n\n')
+
+ # downloading original file
+
if File:
- Command = 'youtube-dl --get-filename --restrict-filenames -o \'' + File + '.%(ext)s\' ' + URL
+ Command = 'youtube-dl --get-filename --restrict-filenames -o \'' + File + '.original.%(ext)s\' ' + URL
else:
- Command = 'youtube-dl --get-filename --restrict-filenames ' + URL
+ Command = 'youtube-dl --get-filename --restrict-filenames -o \'%(title)soriginal.%(ext)s\' ' + URL
Video = get_response(Command)[0].strip().decode('utf-8')
- Command = 'cd ' + Storage + '/' + Directory + ' && sudo youtube-dl --restrict-filenames -o ' + Video + ' ' + URL
+ if os.path.isfile(Storage + '/' + Directory + '/' + Person + '/' + Video):
+ print('<br /><br /><b><span style="color: red">File already exists:</span></b> ' + Directory + '/' + Person + '/' + Video + '')
+ print('<br /><br /><a href="/download.py"><b>Download next file...</b></a>')
+
+ exit()
+
+ print('<br /><br /><b>Downloading original video file...</b>')
+ Command = 'sudo mkdir -p ' + Storage + '/' + Directory + '/' + Person + ' && cd ' + Storage + '/' + Directory + '/' + Person + ' && sudo youtube-dl --restrict-filenames -o ' + Video + ' ' + URL
Error = get_return(Command)
- print('Content-Type: text/html\n\n')
+ if Error == 0:
+ print('<br /><b><span style="color: green">Downloaded successful:</span></b> <a href="/' + Directory + '/' + Person + '/' + urllib.parse.quote(Video) + '">'+ Directory + '/' + Video + '</a><br>')
+ Status = 'successful'
+ else:
+ print('<br /><b><span style="color: red">Download unsuccessful:</span></b> ' + Directory + '/' + Video)
+ Status = 'unsuccessful'
+
+ with open('download.txt', 'a') as file:
+ file.write(Date + ' ' + User + ' ' + Status + ' ' + Directory + '/' + Person + '/' + Video + ' ' + URL + '\n')
+
+ # downloading best mp4
+
+ if File:
+ Command = 'youtube-dl --get-filename --restrict-filenames -f best[ext=mp4] -o \'' + File + '.streaming.%(ext)s\' ' + URL
+ else:
+ Command = 'youtube-dl --get-filename --restrict-filenames -f best[ext=mp4] -o \'%(title)sstreaming.%(ext)s\' ' + URL
+
+ Video = get_response(Command)[0].strip().decode('utf-8')
+
+ print('<br /><br /><b>Downloading mp4 video file...</b>')
+ Command = 'sudo mkdir -p ' + Storage + '/' + Directory + '/' + Person + ' && cd ' + Storage + '/' + Directory + '/' + Person + ' && sudo youtube-dl --restrict-filenames -f best[ext=mp4] -o ' + Video + ' ' + URL
+
+ Error = get_return(Command)
if Error == 0:
- print('\n\nDownloaded successful: <a href="/' + Directory + '/' + urllib.parse.quote(Video) + '">'+ Directory + '/' + Video + '</a><br><br /><a href="/download.py">download next file</a>...')
+ print('<br /><b><span style="color: green">Downloaded successful:</span></b> <a href="/' + Directory + '/' + Person + '/' + urllib.parse.quote(Video) + '">'+ Directory + '/' + Video + '</a><br>')
Status = 'successful'
else:
- print('\n\nDownload unsuccessful, try <a href="/download.py">again</a>...')
+ print('<br /><b><span style="color: red">Download unsuccessful:</span></b> ' + Directory + '/' + Video)
Status = 'unsuccessful'
with open('download.txt', 'a') as file:
- file.write(Date + ' ' + User + ' ' + Status + ' ' + Directory + '/' + Video + ' ' + URL + '\n')
+ file.write(Date + ' ' + User + ' ' + Status + ' ' + Directory + '/' + Person + '/' + Video + ' ' + URL + '\n')
+
+ print('<br /><br /><a href="/download.py"><b>Download next file...</b></a>')
exit()
diff --git a/html/download.html b/html/download.html
index 88e8acf..c450a5a 100644
--- a/html/download.html
+++ b/html/download.html
@@ -1,6 +1,6 @@
<html>
<head>
- <title>YouTube Download</title>
+ <title>Download</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
</head>
@@ -8,25 +8,19 @@
<div class="container">
<div style="margin-top: 2rem"></div>
- <h1>YouTube Download</h1>
+ <h1>Download <small>(<a href="https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md">supported sites</a>)</small></h1>
<form action="download.py" method="post">
<div class="form-group">
- <input type="text" name="file" class="form-control" placeholder="Dateiname (optional)" autofocus>
-
- <div style="margin-top: 1rem"></div>
-
- <input type="text" name="url" class="form-control" placeholder="URL">
-
- <div style="margin-top: 1rem"></div>
-
- <select name="directory" class="form-control">
+ <select name="directory" class="form-control" autofocus size="17">
+ <option value="BA_Comp_cr_P">BA Comp cr P</option>
<option value="BA_Jazz">BA Jazz</option>
<option value="BA_Klassik">BA Klassik</option>
<option value="BA_MuB">BA MuB</option>
<option value="BA_Sound_Arts">BA Sound Arts</option>
<option value="MA_Comp_Jazz">MA Comp Jazz</option>
<option value="MA_Comp_cr_P">MA Comp cr P</option>
+ <option value="MA_Comp_cr_P_composerPerformer">MA Comp cr P composerPerformer</option>
<option value="MA_Ped_Jazz">MA Ped Jazz</option>
<option value="MA_Ped_Klassik">MA Ped Klassik</option>
<option value="MA_Ped_Rhythmik">MA Ped Rhythmik</option>
@@ -38,6 +32,20 @@
<option value="test">test</option>
</select>
+ <div style="margin-top: 1rem"></div>
+
+ <input type="text" name="person" class="form-control" placeholder="Person (optional; ohne Leerzeichen)" size="30">
+
+ <div style="margin-top: 1rem"></div>
+
+ <input type="text" name="file" class="form-control" placeholder="Dateiname (optional; ohne Leerzeichen)" size="30">
+
+ <div style="margin-top: 1rem"></div>
+
+ <input type="text" name="url" class="form-control" placeholder="URL" size="30">
+
+ <div style="margin-top: 1rem"></div>
+
<button type="submit" class="btn btn-success">Download</button>
</div>
</form>
@@ -48,8 +56,11 @@
<h4>TODO:</h4>
<ul>
+ <li>namens directories als drop-down anzeigen</li>
+ <li>download in temp und dann atomar in destdir verschieben</li>
+ <li>periodisches transcoden und ersetzen orig nach mp4</li>
+ <li>directories mit leerzeichen handelnd</li>
<li>show youtube-dl process output waehrend download</li>
- <li>aktuell wird immer "bestes" format runtergeladen; falls das nicht mp4 ist, automatisch nach mp4 transcoden</li>
</ul>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>