Search code examples
pythonwebviewpyqt5widevine

Enable secure playback, Widevine DRM in python webbrowsers (Protected content)


I'm trying to use the spotify web player on a python browser windows.

I try it in two ways:

import webview
webview.create_window('spotify', 'https://open.spotify.com')
webview.start()
import sys
import time

from PyQt5.Qt import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
web = QWebEngineView()
web.load(QUrl("https://open.spotify.com/"))
web.showFullScreen()
sys.exit(app.exec_())

After I log in with my account I get:

Enable secure playback in your browser.

Is there way I can do this? In the spotify support page it tells me to enable protected content playback or play drm. I am not sure if it is possible.


Solution

  • By @metatoaster 's suggestion, I tried to set the QTWEBENGINE_CHROMIUM_FLAGS environment variable to --widevine-path="/home/<myusername>/.mozilla/firefox/237oaqbb.default-release/gmp-widevinecdm/4.10.2449.0/libwidevinecdm.so"

    After I got the location from locate libwidevinecdm.so, and it worked!

    I tried with the spotify's path for the library but that didn't work.