mediathek-download script
This commit is contained in:
parent
60c2992f49
commit
50d7dde4f7
2 changed files with 153 additions and 0 deletions
73
mediathek-download/README.org
Normal file
73
mediathek-download/README.org
Normal file
|
@ -0,0 +1,73 @@
|
|||
* =mediathek-download=
|
||||
|
||||
=mediathek-download= is a simple [[https://fishshell.com][fish]] script for downloading videos form the
|
||||
mediatheks from ZDF, ARD and similar one who split and devliver the video in
|
||||
segments. Additional to download the video, it combines it to one file and
|
||||
converts it to mp4. Currently it only handles /.ts/ files.
|
||||
|
||||
** Preparation
|
||||
|
||||
The following software is required to run this script:
|
||||
|
||||
- [[https://fishshell.com][fish]]
|
||||
- [[https://curl.haxx.se/][curl]]
|
||||
- [[https://ffmpeg.org/][ffmpeg]]
|
||||
|
||||
It may be convenient to make the script executable with =chmod +x mediathek-download.fish=.
|
||||
|
||||
** Executing
|
||||
|
||||
It is assumed, that the script is executable as shown before. If it isn't
|
||||
prepend the executions with =fish=.
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
./mediathek-download.fish <number of sequences> <URL before segment number> [URL after segment number]
|
||||
#+END_SRC
|
||||
|
||||
The first to arguments are required, while the last one is optional. The
|
||||
number of sequences and the URL can be extracted from the developer tools of
|
||||
your browser. Read the next chapter for more information.
|
||||
|
||||
** Extracting necessary informations
|
||||
|
||||
*** Firefox
|
||||
|
||||
1. Visit the site with the video.
|
||||
2. Open the Developer Tools: /Menu > Web Developer > Network/.
|
||||
3. Make sure only /Media/ and /Other/ are selected in the filter bar (second
|
||||
bar from top in the Developer Tools window).
|
||||
4. It may be necessary to select a specific video quality in the player,
|
||||
especially if it is set to automatic.
|
||||
5. Start the video or, if it autostarted, reload the page.
|
||||
6. Make sure you see some requests containing a /.ts/ file extension
|
||||
7. Jump nearly to the end of the video
|
||||
8. A pattern showing the segment numbers should be visible. Remember the
|
||||
last (and probably highest number), it should be the /number of
|
||||
sequences/.
|
||||
9. Click on the last list entry once the video finished.
|
||||
10. Select and copy the complete /Request URL/
|
||||
11. Split the copied string into the part before and (is existent) the part
|
||||
after the segment number.
|
||||
12. Run the script with the now known parameters.
|
||||
|
||||
*** Google Chrome
|
||||
|
||||
1. Visit the site with the video.
|
||||
2. Open the Developer Tools: /Menu > More Tools > Developer Tools/.
|
||||
3. Select /Network/ in the Developer Tools window
|
||||
4. Make sure only /XHR/ is selected in the filter bar (third bar from top
|
||||
in the Developer Tools window). If nothing is found there after the
|
||||
following stepts, try /All/.
|
||||
5. It may be necessary to select a specific video quality in the player,
|
||||
especially if it is set to automatic.
|
||||
6. Start the video or, if it autostarted, reload the page.
|
||||
7. Make sure you see some requests containing a /.ts/ file extension
|
||||
8. Jump nearly to the end of the video
|
||||
9. A pattern showing the segment numbers should be visible. Remember the
|
||||
last (and probably highest number), it should be the /number of
|
||||
sequences/.
|
||||
10. Click on the last list entry once the video finished.
|
||||
11. Select and copy the complete /Request URL/ in the /Headers/ tab.
|
||||
12. Split the copied string into the part before and (is existent) the part
|
||||
after the segment number.
|
||||
13. Run the script with the now known parameters.
|
80
mediathek-download/mediathek-download.fish
Executable file
80
mediathek-download/mediathek-download.fish
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/fish
|
||||
# Download splitted videos and combine them.
|
||||
# Created for .ts segments, output is a mp4 file.
|
||||
# Limited to videos with less than 9999 segments (which should be enought).
|
||||
#
|
||||
# 2018 (c) Marcel Kapfer
|
||||
# MIT License
|
||||
#
|
||||
# Run with:
|
||||
# ./video.fish <number of sequences> <URL before segment number> [URL after segment number]
|
||||
#
|
||||
# Requirements:
|
||||
# - fish (https://fishshell.com)
|
||||
# - curl (https://curl.haxx.se/)
|
||||
# - ffmpeg (https://ffmpeg.org/)
|
||||
|
||||
set parts_file "./parts.list"
|
||||
set in_ext ".ts"
|
||||
set out_ext ".mp4"
|
||||
set combined_file "./combined"$in_ext
|
||||
set output_file "./out"$out_ext
|
||||
|
||||
function _cleanup
|
||||
if test -f $parts_file
|
||||
rm $parts_file
|
||||
end
|
||||
if test -f $output_file
|
||||
rm *$in_ext
|
||||
end
|
||||
end
|
||||
|
||||
trap _cleanup SIGINT
|
||||
|
||||
if test (count $argv) -gt 3
|
||||
echo "To much arguments given. Aborting."
|
||||
exit 1
|
||||
end
|
||||
|
||||
if test (count $argv) -lt 2
|
||||
echo "No sequence number or URL given. Aborting."
|
||||
exit 1
|
||||
end
|
||||
|
||||
set num_seq $argv[1]
|
||||
set url_1 $argv[2]
|
||||
|
||||
if test (count $argv) -eq 3
|
||||
set url_2 $argv[3]
|
||||
else
|
||||
set -l url_2 ""
|
||||
end
|
||||
|
||||
for segment in (seq $num_seq)
|
||||
# padding for the filename
|
||||
if test $segment -lt 10
|
||||
set file_num "000"$segment
|
||||
else if test $segment -lt 100
|
||||
set file_num "00"$segment
|
||||
else if test $segment -lt 1000
|
||||
set file_num "0"$segment
|
||||
else
|
||||
set file_num $segment
|
||||
end
|
||||
|
||||
# download the segments using curl
|
||||
curl \
|
||||
--output $file_num$in_ext \
|
||||
$url_1$segment$url_2
|
||||
|
||||
# add segment file to file list
|
||||
echo "file './"$file_num$in_ext"'" >> $parts_file
|
||||
end
|
||||
|
||||
## combine the files
|
||||
ffmpeg -f concat -safe 0 -i $parts_file -c copy $combined_file
|
||||
|
||||
## convert
|
||||
ffmpeg -i $combined_file -acodec copy -vcodec copy $output_file
|
||||
|
||||
_cleanup
|
Loading…
Reference in a new issue