Sign up here and you can log into the forum!

Youtube3

UMSP Plugin Depot, the place for sharing plugins & info about them. No requests, just plugins/code.

Re: Youtube3   

Postby NoSubstitute » Sun Oct 18, 2015 7:05 am

Kudos to you mad_ady for keeping some life in the WDTV.

I just moved it into my daughter's room, so she can access the mediaservers/NAS I have.
Previously she had a very limited Android mediaplayer that only found DLNA-servers, and yet refused to list all content.
There is No Substitute!
NoSubstitute
Beta Tester
 
Posts: 206
Joined: Mon Apr 05, 2010 5:56 pm
Location: Malmö, Sweden

Re: Youtube3   

Postby mad_ady » Sun Oct 18, 2015 8:16 am

Excellent! She can betatest the VEVO feature then. I hear it's where the cool kids keep their music these days...:D
User avatar
mad_ady
Developer
 
Posts: 4566
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Youtube3   

Postby hszhsz » Tue Nov 17, 2015 12:36 pm

Hello All,

I've managed to run youtube3 on 1.06.43 firmware without any crash. I'd like to share my finding and a dirty solution for it.
I hope someone will pick it up and polish the code. Due to the lack of freetime, I'm unable to make custom firmware for you, but if you know how to build custom root.bin and have some linux experience, then you're good to go.

I've always used 1.06.43 since it has been released. YouTube leanback uses v3 API which is still supported by YouTube.
In the last couple of months, I realized that watching youtube videos crashes the device. Specifically, at the end of the video, the WDTV rebooted itself.
So I modified the WDTV's default gateway pointing to my notebook, with a man-in-the-middle proxy (apt-get install mitmproxy, http://docs.mitmproxy.org/en/stable/transparent/linux.html). I found that a few seconds before the video ends, WDTV fetches an url like https://www.youtube.com/set_awesome/bla/bla/bla. That made WDTV to reboot. If somehow the /set_awesome part of the query could be skipped, then WDTV would continue to work properly.

I dug deeper. I changed from mitmproxy to apache2 + ssl + reverse proxy to filter out the /set_awesome part of it. If you're familiar with apache2, the relevant part of the config was:
Code: Select all
        SSLProxyEngine On
        ProxyPreserveHost On
        ProxyPass /set_awesome !
        ProxyPass / https://youtube-ui.l.google.com/
        ProxyPassReverse / https://youtube-ui.l.google.com/


And it worked. WDTV could play YouTube videos without crashing itself. I was a bit sad, because my laptop must have been powered on to do the youtube proxy thingy.

Then I started to port the apache reverse proxy to the WDTV itself.

The base was the factory default 1.06.43 image.

The following things was needed to success:
1. A self-signed ssl key + certificate to http://www.youtube.com domain - WDTV checks if the remote server's certificate is trusted by the CA store stored internally (/etc/stagecraft-data/ssl/certs/ca-bundle.crt)
2. Some apache binaries, init scripts and libraries.
3. Modified /init script to start apache2 instead of lighttpd. Lighttpd can't do ssl reverse proxy things (it is a limitation known by their developers)
4. Properly crafted apache configuration: denied /set_awesome and proxy everything else.
5. Modified /etc/hosts file to cheat on WDTV:
127.0.0.1 WDTVLIVE http://www.youtube.com

Because "sharing is caring":
- Modifications on 1.06.43 to handle the Youtube properly: http://hsz.tmp.hu/wd/diff.txt
- The ready-to-run root.bin: http://hsz.tmp.hu/wd/root-1.06.43-3.bin

The only known issue with this root.bin is sometimes apache2 reverse proxy has dns resolv issues, I believe that apache2 starts way before network is ready for use and caches negative dns responses. There are at least two possible solutions:
- make apache start when network is ready (/init hacking needed)
- put "173.194.44.8 youtube-ui.l.google.com" in /etc/hosts - in this case, apache2 reverse proxy doesn't have to resolv the proxypass directive by dns because it can be found in local hosts file.

Feel free to ask if you have any questions.
hszhsz
n00b
 
Posts: 1
Joined: Tue Nov 17, 2015 12:07 pm

Re: Youtube3   

Postby mad_ady » Wed Nov 18, 2015 12:00 am

Excellent workaround!

I see two approaches to improving it:
1. Scan DMAOSD or locate the Youtube leanback code and look inside for that URL string. Try replacing that string with a hex editor to something else (127.0.0.1?) keeping the string length (terminate it with NULL \0).
2. Continue the WDLXTV port work on 1.06. I started it early this year, but haven't had time (and motivation) to continue it. You should have a working root.bin with xmount support so far: http://forum.wdlxtv.com/viewtopic.php?f=38&t=9073. You could (if you have time) continue to add features from WDLXTV to it, or just add your work to it - it's up to you.

Anyway, great work!
User avatar
mad_ady
Developer
 
Posts: 4566
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Youtube3   

Postby nixxo » Sun Nov 22, 2015 12:52 am

Hi, i'm on Gen3 wdtv and youtube3 doesn't work.

testing the plugin via web-end gives me this error.

Code: Select all
Fatal error: Call to undefined function json_last_error() in /tmp/umsp-plugins/youtube3/youtube3.php on line 466


The json_last_error function is only available from php 5.3 and on my device the php version is this:
Code: Select all
PHP 5.2.17 (cli) (built: Aug  4 2014 14:10:26)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies


Everyone else has this problem?
nixxo
WDTVer
 
Posts: 35
Joined: Sat Oct 17, 2015 12:11 am

Re: Youtube3   

Postby mad_ady » Sun Nov 22, 2015 11:13 pm

Thanks for the feedback. The php version in Gen3 is the one compiled by WD (KAD told me this). I offered my php version to KAD, but he glanced over the features it provides and decided to keep the original one.

You could in theory replace your php version with the one in Live, but you run in the risk of breaking other things. I will talk to KAD again, see if he wants to try again...
User avatar
mad_ady
Developer
 
Posts: 4566
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Youtube3   

Postby nixxo » Sun Nov 22, 2015 11:33 pm

mad_ady wrote:Thanks for the feedback. The php version in Gen3 is the one compiled by WD (KAD told me this). I offered my php version to KAD, but he glanced over the features it provides and decided to keep the original one.

You could in theory replace your php version with the one in Live, but you run in the risk of breaking other things. I will talk to KAD again, see if he wants to try again...

glad I can help...

it seems odd to me that i'm the first one to report this thing.
nixxo
WDTVer
 
Posts: 35
Joined: Sat Oct 17, 2015 12:11 am

Re: Youtube3   

Postby mad_ady » Mon Nov 23, 2015 5:34 am

I guess you're the first Gen3 user of this plugin...
User avatar
mad_ady
Developer
 
Posts: 4566
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Youtube3   

Postby nixxo » Mon Nov 30, 2015 10:37 am

I slightly modified youtube3 in order to get it to work on Gen3 since json_last_error is not available prior to php 5.3

It's probably a little less safe, but it's hard, imho, for youtube to provide incorrect/malformed jsons from api requests.

I replaced both the two json_last_error occurences from:
Code: Select all
$json = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {

to:
Code: Select all
$json = json_decode($response, true);
if ($json != null) {


And it works. I can watch youtube.
nixxo
WDTVer
 
Posts: 35
Joined: Sat Oct 17, 2015 12:11 am

Re: Youtube3   

Postby mad_ady » Mon Nov 30, 2015 11:49 am

Great! I'll patch it in the official version to make it Gen3 compliant.
Thanks!
User avatar
mad_ady
Developer
 
Posts: 4566
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

PreviousNext

Return to UMSP Plugins

Who is online

Users browsing this forum: No registered users and 4 guests