 Hello and welcome today. We're gonna be looking at streaming TV shows and movies or getting links to download TV shows and movies From your Linux shell now, of course I want to point out that depending on what it is you're streaming or downloading this may or may not be legal. So make sure that What's your streaming is legal for you to stream where you live? That's the disclaimer. Let's go ahead and get started We're gonna be using a website called watch dash series dot co This is the URL to their search Page so I'm just gonna go through this. I'm gonna run through these commands There are basically three different steps to this and of course you can put this into a shell script to automate it But we're just gonna manually take this. I'm gonna use W get With the dash Q option for quiet the capital O and dash mean standard output So we're gonna be typing just the the code from the page To our shell so here we are searching now. We need to give it key words. We're gonna be looking for a movie called flying Deuces I think I spelt that right It's a old Laurel and Harding movie that to the best of my knowledge from I've looked up online is now in the public domain So we should have no problem legally Downloading and or streaming this video to the best of my knowledge again. I'm not a lawyer Let's go ahead and do that and you see it gives us some output here And what we're gonna be looking for is a link So when you do a search it gives up a list of all movies and TV shows under that And then we need to grab that URL to go into that And then we need to grab the episode we want and then we can get the URL for the video So this is the first step just doing the search. So let's go ahead and what we're gonna search for now is We'll just grep again the grep-i Flying to see what comes up as far as URLs here. It is series is what we're looking for So we're gonna be looking for these links that say series and how do we get that when there's Multiple options here. We can look at other things in our search return here But what we'll probably look for here is Probably this view more let's see what happens when we search actually, let's see what happens Yeah, let's do that. So it's just a trial and error here at first We don't need the dash I anymore. There's one very specific search. Oh good That returns just one thing and so there's only one option for that and of course then we can Use cut and we can cut with a delimiter of question or quotation marks And we want the second so go dash f2 for field 2 and that will give us the URL Of course, it's the URL without the domain, which means we just have to add this first part here to that Which we can automate with a script, but just real quick Let's say that we were searching for something that has multiple returns So flying users only returns one. I'm gonna search for Star Wars And here we'll get a list of movies and of course you can pipe this into something like fcf if you have it installed Which is real nice, and then we can do something like Return and get return of the Jedi or something like clone wars and then we can pick the season that we want here I'm gonna hit that it returns that so now that we have learned how to get The URL to the series we now need to use that to get the URL to the episode and even if it's movie There's usually a link to the episode which would be usually either zero or one in that URL So basically we're gonna take what we've returned So let's go back up to flying deuces and we'll cut that we'll get that now the next step again Let's clear the screen. W get dash q o dash for quiet and standard output and whoops That's a that's from the end of the video. I pasted the wrong thing We'll go ahead and paste this but again. We need the the series at the beginning here, so we'll do This right here, and we'll put that at the beginning and now when we do that it returns the page for That series so now we're gonna be looking for episodes. Let's go ahead and grep for Episode and see what turns up. There we go. So we have a few different things that return And let's just go ahead and pick one of these We're gonna go ahead, and I think that doing one of these classes Let's see if it returns that might return more than one It looks like it, but let's go ahead and just now instead of gripping for episode We'll grab for that and it gives us to return so then we can use head dash and one to get just that first line And of course we can pipe that into cut dash D for a delimiter and we will say field two here and there we go We have our URL to that episode which in this case is a movie and So we will now again go back to W get q dash o I can try dash q o dash and We will take again our domain so that will always be the same So if you were to put this in a script you probably put that into a variable and use it over and over again For each thing you grab so now we've got the episode now if I real quick grep the code of that page I can do something like open load open load is one of the many servers They use to load these videos and TV shows on to think about this website this watch series dot CO Yeah, they use multiple different servers and not every page is going to have an open load link So we want to look we got a list of all the servers. That's what we want is a list of all their servers So looking at this again, we can go data dash videos So instead of searching for open load We will get a every line that has data dash video on it and that's a list of all our servers And of course we can use cut dash D quotation marks again. We'll count one two three four five Six I think is what we want here One two three four five six data first one's a little different, but let's just go ahead and do dash F six And there we go. We have a list of servers now You can't just take that link and put it into most video players because they're not gonna know how to do it certain players like MPV if you have YouTube DL installed will get the link and play it But most other players won't especially if you want to send it to your kodi box or something like that We want to get the actual link to the video So what we're going to do is we're going to use YouTube DL to look through all of these So we will take that output We'll take that into a while read. We'll do you for URL do Done and we'll say YouTube DL, which we don't want to download the video right now We want to dash G which means get the direct URL to the video file So I'll take that and we will say dollar sign you and when we do that it should go through each of those URLs and if that Website like open load or Stream mango they if they're supported by YouTube DL We should get a direct link to the video file now be aware that most these sites generate a URL For you when you go to watch the video, so you can't take this URL and send it to somebody else because it'll be based on Lots of times your IP address and they'll have a time limit that they will expire at But just for right now downloading or playing it on your system This should work, but we have a lot of warnings for the websites that aren't supported So what we want to do now is go to our YouTube DL thing here and we will say to pipe Dev No, and what that will do is it will get rid of any errors So we're only going to get the output of workable URLs So there's a URL there's a URL and I should be able to take that and on this current system as long as I use it right now And I don't wait I should be able to put these any of these links into any media player that can stream videos And it should stream, but we don't need them all we just want one one thing We can do we can try doing head and just say oh we just want whatever the first return is the problem with that is we'll get the first URL and Then The script is still running the script is throwing because it's still getting all the other URLs It's just not displaying to the screen the head command saying just return the first one So a better option instead of doing that because that's going to take 30 seconds to run really it should only be 10 seconds What we'll do is we'll get rid of the head command and right here after W Or they're sorry the YouTube DL command we'll say ampersand ampersand which means if successful will say Break which means as soon as we get a URL that works break out of the loop. We do that. We should get that first URL and then the script should end Perfect. So now we can take this URL and again, I can use W get to download it I can use curl to download it. I can put it into VLC or MPV or whatever media player I use Or I like to use axel. I'm downloading that way I can say hey make 10 connections that will download a little bit faster So that's how that works. So I mean we could take this and again MPV would already be able to do this without running through all of it Every bit of this summit will need for scraping the page but I can say MPV and I go like that, you know putting inside the Question or sorry dollar sign quotations and the video starts playing again This video should be in the public domain So no problem with you guys streaming that if you want to the best of my knowledge again I'm not a lawyer So again, we went through things quickly here, but again, there were three steps searching for the video. So we can do that again We'll do Fuzzy finder here and said Star Wars will say Fine, I don't need to do the full name. There it is and that returns the link to that And that'll be the movie or series, but then we need to get the episode So we did that and then after we get the episode We can then grep that page for all the servers use YouTube DL to get a direct link to the video piping all the errors to the unsupported servers to dev null and then breaking out of the loop once we get a usable URL so again I put this MPV or I can use W get or I could use and using W get in this case We'll give you a funny file name So you definitely want to use W get and these dash. Oh, whatever the name of your movie mp4 They're always going to be mp4 so you can you know that for sure Another one would be like I said axle which I've done videos on before dash n and then we'll say 10 and then we'll say dash Oh lower case. Oh in this case Whatever name for a movie mp4 and that will actually make 10 connections to that server You don't want to really do more than 10 because then you might get booted from that server But that definitely does speed it up. You'll definitely get Faster speeds and just using W get Yeah, I hope you found this useful again We used it for a public domain movie Be sure that you don't get in trouble by doing something illegal with this This is just a lesson in website scraping and streaming videos from the shell. I hope you found that useful This is I wouldn't say in advance but more of a medium Tutorial I should have said that at the beginning, you know medium knowledgeable user So anyway, thank you for watching and I hope that you have a great day