1

I'm trying to stream videos from YouTube in a GUI app using PyQt5, python-vlc and pafy modules, but vlc gave me some connection errors:

[0000025466dc7340] main tls client error: connection error: Interrupted function call
[0000025466df9f00] access stream error: HTTP connection failure
[0000025466dc7430] gnutls tls client error: TLS handshake error: Error in the push function.
[0000025466dc7430] main tls client error: TLS session handshake error
[0000025466dc7430] main tls client error: connection error: Interrupted function call
[0000025466dfa080] access stream error: HTTP connection failure

When I make the same thing with tkinter module it works without problems. How can I solve these errors?

def OnYT(self):
    text = self.textbox.text()
    url = self.Search(text) #this function returns the first result url from a search on YouTube 
    self.textbox.setText("")
    video = pafy.new(url)
    best = video.getbest()
    self.mediaplayer.set_mrl(best.url)

    if sys.platform.startswith('linux'):
        self.mediaplayer.set_xwindow(self.videoframe.winId())
    elif sys.platform == "win32":
        self.mediaplayer.set_hwnd(self.videoframe.winId())
    elif sys.platform == "darwin":
        self.mediaplayer.set_nsobject(int(self.videoframe.winId()))

    self.mediaplayer.play()
INeed ADollar
  • 46
  • 2
  • 9
  • do you updated both of `youtube-dl` and `pafy` ? – LinPy Jun 12 '19 at 11:10
  • I don't think the problem is from these modules because when I take the stream link returned by pafy and type it in a browser it works but vlc cannot connect to this stream. P.S. I updated these modules too – INeed ADollar Jun 12 '19 at 11:26

1 Answers1

0

there is a work around for this , you can configure VLC to connect to URL using http using the parameter vlc.Instance("prefer-insecure")

or you can try to update and feed VLC with certificates:

 sudo update-ca-certificates --fresh --verbose
 mkdir -p ~/.local/share/vlc/certs/
 cat /usr/share/ca-certificates/mozilla/* | tee ~/.local/share/vlc/certs/ca-certifcates.crt

you can find more info here

GNUtls options:

 --gnutls-system-trust, --no-gnutls-system-trust 
                             Use system trust database
                             (default enabled)
      Trust the root certificates of Certificate Authorities stored in the
      operating system trust database to authenticate TLS sessions.
  --gnutls-dir-trust <string> 
                             Trust directory
      Trust directory
  --gnutls-priorities {PERFORMANCE,NORMAL,SECURE128,SECURE256,EXPORT} 
                             TLS cipher priorities
      Ciphers, key exchange methods, hash functions and compression methods
      can be selected. Refer to GNU TLS documentation for detailed syntax.

you could use --gnutls-dir-trus to point to firefox certs I think

LinPy
  • 16,987
  • 4
  • 43
  • 57
  • I tried this: ```vlc.Instance(['--prefer-insecure'])``` but it gaves me this error: ```vlc: unknown option or missing mandatory argument `--prefer-insecure' Try `vlc --help' for more information.``` – INeed ADollar Jun 12 '19 at 11:52
  • Thank you very much! The part with http is solved, but do you know how to solve these errors? :) ```[000001faa4616170] main tls client error: connection error: Interrupted function call [000001faa7ff4d90] mkv demux error: unable to read KaxCluster during seek, giving up [000001faa7ff4d90] mkv demux error: unable to read KaxCluster during seek, giving up [000001faa4616da0] main tls client error: connection error: Interrupted function call``` – INeed ADollar Jun 12 '19 at 12:13
  • Can you tell me how to solve this problem? I met the same problem on window. – mikezang Apr 22 '20 at 04:35