Open 4ndriH opened 5 years ago
My guess would be that youtube/google itself resets your token/connection after this amount of time.
My guess would be that youtube/google itself resets your token/connection after this amount of time.
Wouldn't this cause the stream you are watching on YT itself to stop as well? I had the stream open next to the CMD and it was still running there. Thinking about it, it might still be a token/connection thing with YT just refreshing it periodically. In that case it should be possible add a similar function to youtube-dl (maybe only when a stream is detected).
My guess would be that youtube/google itself resets your token/connection after this amount of time.
Wouldn't this cause the stream you are watching on YT itself to stop as well? I had the stream open next to the CMD and it was still running there.
Nah. Like, even Google would think about that possibility, and stealthily reset.
The token reset seems like a possibility here. YouTube might be refreshing the token after every 6 hour
I made a bash script to get a new m3u8 url when ffmpeg stops running. Feel free to use and adapt this to whatever you need.
#Explanation:
#
#function get() will take 3 paramaters: param 1 is the youtube uri, param 2 is the directory to download to, param 3 is the filename format (includes extension, such as .ts)
#get() then passes these args to function newurl(), along with an extra param which is a starting number for multiple files in the format 1test.ts, 2test.ts and so on. a new video file is created when ffmpeg stops (due to the m3u8 url expiring after 6 hrs)
#
#newurl() has 4 input params, 1 is the url, 2 is the directory, 3 is the file name, 4 is the number (from either get() or again())
#newurl() sets its own local vars from the params it gets, and adds one to the temp file number when it gets called again from again()
#newurl() then passes those params over to again()
#
#again() takes 5 params, 1 is the file number, 2 is the m3u8 stream url, 3 is the directory, 4 is the file name, 5 is the youtube video url (to be returned to newurl() when the stream url expires)
#
#Example usage: get "https://www.youtube.com/watch?v=21X5lGlDOfg" "C:\tmp" "NASA_TV.ts"
again() {
tempnum=$1
ffmpeg -i $2 -c copy $3$1$4 && newurl $5 $3 $4 $1 #ffmpeg downloads youtube stream to directory, then calls newurl() when ffmpeg stops
}
newurl() {
local m3url=$(youtube-dl -f best -g $1) #store m3u8 stream url from youtube-dl as string
local tempnum=$4 #file number, this is sent to again() so again() can send it back
local tempdir=$2 #also sent to again so it can be sent back
local tempfilename=$3 #also sent to again so it can be sent back
let tempnum+=1 #add 1 to file number recieved from arguments
again ${tempnum} ${m3url} ${tempdir} ${tempfilename} $1 #send required args to again(), and also send url so it can be sent back to newurl()
}
get() {
newurl $1 $2 $3 0 #send args
}
#get "url" "directory" "filename"
As I have never used bash I do not understand how I get it to run. I do get "hello world" scripts to run but I am lost with the get command you have. Like do I just write: m3u8.sh get "URL" "dir" "file" or do I have to first enter the file and then the get command? Both do not seem to work for me. I am on a windows 10 machine if this has an impact.
Hi, you can run the script by installing git bash on windows. I haven't coded it to work with command line parameters, so you'll have to edit the bash file and change the command to what you need. When git bash is installed, .sh files will automatically be associated with it. Make sure you have ffmpeg installed and in your PATH.
Hi, Got it working. Thanks a lot for the script. It works like a charm!
Same issue. I dont think that it's a url problem as i can continue downloading just by entering the same command after crash. This is a major issue and it is a shame that for more than a year nobody has fixed it.
I have been downloading live streams on YouTube and noticed that it always ends after 6 hours (+/- a few seconds). At first I thought its something with youtube-dl but after recording it with VLC I got the same result. I looked through the help article but could not find anything related to this. Is there anything you can do about it? I am aware that this is not the most pressing issue there is because few people are downloading such long live streams (at least I think so) and it might prove difficult to find a solution for this because it seams to be something on YouTube's side.
Due to the immense code output I can not add much of value. I will try my best though.
That is the final output of the download. The part before "[https @ 0000017b829a69c0] HTTP error 403 Forbidden" fills the rest of my cmd window and is not of much use imo.
cheers
PS: In case the devs deem this unnecessary or unsolvable do not hesitate to close this Issue.