warren-bank / Android-WebCast

Android app to extract video (file/stream) URLs from websites and watch them elsewhere (internal/external video player, Google Chromecast, ExoAirPlayer).
GNU General Public License v2.0
97 stars 17 forks source link

Unable to cast YouTube videos #5

Closed rajBopche closed 3 years ago

rajBopche commented 3 years ago

I am able to cast the videos on my TV from abcNews very well. But it does not work for any of the YouTube videos. In fact when the YouTube videos are searched they don't list on the left side drawer in the same manner as abcVideos did?

See how the left drawer contains the video listing available on abcnews site

Screenshot_2021-03-10-14-25-39-296_com github warren_bank webcast

However in case of YouTube the video listing section is completely empty

Screenshot_2021-03-10-14-29-07-726_com github warren_bank webcast

warren-bank commented 3 years ago

Not an error with the application; the video player on the Youtube website does a good job masking its network traffic such that the application is unable to detect its video stream(s). Site-specific logic would be needed. A greasemonkey userscript would be better suited for that task.

warren-bank commented 3 years ago

If you feel like a homework assignment..

If you feel like it, you're welcome to port the Youtube userscript from desktop to Android. It wouldn't need any code to modify DOM.. only code to find and forward the video URL.

rajBopche commented 3 years ago

Kudos to quick response, haven't really worked with greaseMonkey but surely looks interesting.

warren-bank commented 3 years ago

At the moment, I'm pretty focused on something else.. but at some point I'll circle around to looking at this. It shouldn't be too difficult. I didn't originally bother to port that script since YT's video player has a Chromecast sender already built it.

However, dealing directly with the mp4 video file URL has benefits:

rajBopche commented 3 years ago

Ended up running Python on Android to extract the actual YT's downloadable url.

After setting up Chaquopy and then importing PyTube on Android all I needed was this line.

py.getModule("pytube").callAttr("YouTube",
            "https://www.youtube.com/watch?v=FT6XaOrZhsA").get("streams").asList().get(0).get("url").toString()

Note: Python Object Instantiation on Android was terribly slow. Use threads.