gort818 / qtwebflix

A qt webengine program for netflix
GNU General Public License v3.0
245 stars 29 forks source link

Possible to set user agent? Raspberry pi support #12

Closed owenthewizard closed 5 years ago

owenthewizard commented 6 years ago

Is it possible to set the user agent? For example to be able to use this to watch Netflix on the Raspberry Pi.

gort818 commented 6 years ago

You can, but just curious why would you need to?

gort818 commented 6 years ago

You can set the user agent by adding this lines in mainwindow.cpp

//QString UserAgent = "user agent goes here";
//this->webview->page()->profile()->setHttpUserAgent(UserAgent);
omni6 commented 6 years ago

i think it should work if you simply run: netflix -user-agent="Mozilla/5.0 (X11; CrOS armv7l 6946.86.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.91 Safari/537.36"

user agent for chromeos (you know that you will need the widevine libs from the chrome recovery image to get it work on arm platforms?)

owenthewizard commented 6 years ago

@omni6 Didn't work, according to this tool; @gort818's method worked.

gort818 commented 6 years ago

@owenthewizard I am glad it worked, just curious is there a specific reason you need to set the user agent. If it is really needed I can add a way to change it.

owenthewizard commented 6 years ago

@gort818 Playing Netflix on the Raspberry Pi requires the user agent to be spoofed, as per @omni6's comment.

gort818 commented 6 years ago

@owenthewizard Ok did not know that.. I might be able to add something that checks if you are running raspberry pi and and set it to chromeos.. what do you think? would that make it easier?

owenthewizard commented 6 years ago

@gort818 That would be nice, I was going to do that in my fork but you could probably do it better as I don't have experience with Qt.

gort818 commented 6 years ago

Ok I will leave this open.. I might have it done today

gort818 commented 6 years ago

@owenthewizard ok I just updated it can you give it a go and see if it works?

owenthewizard commented 6 years ago

@gort818 What version of chromium-widevine should I extract widevine from (if it matters)? Alternatively, where can I find a download of 61.0.3163.140? Debian and Arch don't seem to have it anymore.

gort818 commented 6 years ago

What distro are you on?

I found this https://github.com/kusti8/chromium-build/releases/download/netflix-1.0.0/chromium-browser_56.0.2924.84-0ubuntu0.14.04.1.1011.deb

Here is it on arch https://archive.archlinux.org/packages/c/chromium/chromium-61.0.3163.100-1-x86_64.pkg.tar.xz but it is for x86

omni6 commented 6 years ago

Download for arm? No way afaik. A while ago i commented this https://archlinuxarm.org/forum/viewtopic.php?f=47&t=11600#p56272 but the .deb package dissapeared. You can try something like this: https://forum.vivaldi.net/topic/23226/widevine-and-flash-for-vivaldi-on-arm-spotify-and-tidal-access https://help.vivaldi.com/article/raspberry-pi/

But generally you have to extract this two files out of the chros-recovery into this directory:

/usr/lib/qt/plugins/ppapi/libwidevinecdm.so
 /usr/lib/qt/plugins/ppapi/libwidevinecdmadapter.so
owenthewizard commented 6 years ago

Extracting the widevine libraries from @kusti8's package was a success!

Tested on Arch Linux ARM, Netflix works as expected, however the resolution and framerate are nothing to write home about. I suspect this is because ffmpeg on Arch Linux ARM was not compiled with the the MMAL-accelerated h264 codecs. I will recompile ffmpeg and report back.

gort818 commented 6 years ago

O nice! at least we got it going! Did my fix for the Useragent work as intended?

owenthewizard commented 6 years ago

@gort818 Indeed! I saw the user agent change and 1080p unlocker on stdout.

owenthewizard commented 6 years ago

Recompiling ffmpeg didn't make much of a difference that I could tell, maybe the Arch Linux ARM Qt5-webengine package doesn't use system-ffmpeg? Although I think it would as it does in upstream Arch.

gort818 commented 6 years ago

I wish I had an extra raspberry pi but there are all busy as headless servers. I wonder if streaming at 1080p it bogging down the cpu.. check your cpu temps when streaming it might be throttling.

gort818 commented 6 years ago

@owenthewizard what model pi do you have? Also if you have a time could you do a quick how you got it running on your pi, I would like to add it to the readme for other users.

omni6 commented 6 years ago

You're sure that qt5-webengine uses hardware acceleleration (egl)? Had problems to get this work on my odroids but i know that compatiblity is better with raspi. Does it play youtube in hd & fullscreen flawless?

omni6 commented 6 years ago

@owenthewizard can you test this?

pkgname=qt5-webengine-widevine-rpi
pkgver=56.0.2924.84
pkgrel=1
pkgdesc="Widevine libs for rpi"
arch=('armv7h' 'armv6h')
url="https://github.com/kusti8/chromium-build"
license=('custom:proprietary')
provides=('qt5-webengine-widevine')
depends=('qt5-webengine')
makedepends=('binutils')
source=("${url}/releases/download/netflix-1.0.0/chromium-browser_${pkgver}-0ubuntu0.14.04.1.1011.deb")
md5sums=('94504ef46346ecd1260cd590b38d8914')

prepare() {

   tar -xf data.tar.xz

}

package() {

  install -Dm644  ${srcdir}/usr/lib/chromium-browser/libwidevinecdm.so ${pkgdir}/usr/lib/qt/plugins/ppapi/libwidevinecdm.so
  install -Dm644  ${srcdir}/usr/lib/chromium-browser/libwidevinecdmadapter.so ${pkgdir}/usr/lib/qt/plugins/ppapi/libwidevinecdmadapter.so
}

don't forget: qtwebflix --register-pepper-plugins="/usr/lib/qt/plugins/ppapi/libwidevinecdmadapter.so; application/x-ppapi-widevine-cdm

owenthewizard commented 6 years ago

@gort818 I have a Raspberry Pi 3 Model B. Basically I just cloned and built qtwebflix, then extracted the widevine libraries from @kusti8's chromium build.

@omni6 I don't think it's using hardware acceleration because Netflix was much smoother on my Raspbian card, not to mention being in 1080p. I can use the PKGBUILD you provided but I don't see how it is any different than what I did manually. Netflix worked without registering the plugins, do they need to be registered if they're in /usr/lib/qt/plugins/ppapi/?

I'm planning on doing some more testing this weekend. @gort818 is it possible that hardware acceleration is disabled in qtwebflix? I don't know about the internals of qtwebengine but chromium disables hardware acceleration by default on Linux iirc and needs --ignore-gpu-blacklist to override it.

omni6 commented 6 years ago

I can use the PKGBUILD you provided but I don't see how it is any different than what I did manually.

no it is fine if you can do it manually, but if qtwebflix ofiicially support rpi there should be IMO a simple solution to get widevine work.

and needs --ignore-gpu-blacklist to override it.

and --use-gl=egl ?

gort818 commented 6 years ago

@owenthewizard this is with --ignore-gpu-blacklist --enable-gpu-rasterization screenshot_2018-04-07_16-18-13

And with out screenshot_2018-04-07_16-19-38

Can you give that a try and let me know.

Also try

--enable-native-gpu-memory-buffers

To check the settings add this in the providers file for easy access.

gpu=chrome://gpu

owenthewizard commented 6 years ago

Wow I'm an idiot... Netflix runs perfectly smooth with --ignore-gpu-blacklist... I somehow forgot I needed that...

Anyway, attached are screenshots of chrome://gpu with --ignore-gpu-blacklist, --use-gl=egl, --enable-gpu-rasterization, and --enable-native-gpu-memory-buffers. However I would only recommend using --ignore-gpu-blacklist because enabling the last two cause intermittent issues (e.g. black screen) in Netflix. --use-gl=egl didn't seem to have an effect.

@omni6 The PKGBUILD works as expected, but I think you can drop binutils from the makedepends as it is included in base-devel.

Apologies for the 720p screenshots, I'll be able to test on a 1080p screen tomorrow (at the earliest).

screenshot1 screenshot2 screenshot3 screenshot4 screenshot5

Edit: I think it is safe to say that the Raspberry Pi is now a supported platform.

gort818 commented 6 years ago

@owenthewizard awesome glad it is working! @omni6 How would we go about making your PKGBUILD a dependency for arm users?

omni6 commented 6 years ago

Basically it is already a dependency for qtwebflix. This pkgbuild provides=('qt5-webengine-widevine') what is a dependency for qtwebflix. x86_64 users have to take widevine from aur, arm users can use the pkgbuild. But you could update the readme.md and provide the link for arm users.

build requires base-devel group to be installed

mkdir qt5-webengine-widevine-rpi && cd qt5-webengine-widevine-rpi
wget https://gist.githubusercontent.com/omni6/e557af6a67a41343aa859816d0113ced/raw/0c4d4f09cdb295ba47e5022adab4813766262f46/PKGBUILD

makepkg -csi

@owenthewizard raspi 3 is aarch64, right? Tested on my 64-bit odroid and this doesn't work but on your raspi everything was fine... i ask because then i should add aarch64 as architecture...

owenthewizard commented 6 years ago

@omni6 Raspberry Pi 3 technically supports aarch64 but upstream only provides support for aarch32. I used a Raspberry Pi 2 Arch Linux ARM tarball to install (armv7). I am planning on testing aarch64 soon (tm), as according to the Gentoo Wiki video hardware acceleration works under aarch64.

gort818 commented 5 years ago

@owenthewizard there are some new options you can now set useragent from the commandline.

Usage: qtwebflix [options]
Qtwebflix Help 

 To Control playback rate :
 CTRL + W = speed up 
 CTRL + S = slow down 
 CTRL + R = reset to defualt

Options:
  -h, --help                   Displays this help.
  -v, --version                Displays version information.
  -p, --provider <provider>    Set content provider eg. netflix.com
  -u, --useragent <useragent>  change useragent eg. "Mozilla/5.0 (X11; Linux
                               x86_64; rv:63.0) Gecko/20100101 Firefox/63.0"