Cannot play youtube live stream using PyQt - python

I am a new programmer. I am trying to play a youtube live stream in a python program using PyQt and the following code snippet derived from youtube video embedding pyqt.
self.centralwid = QtWidgets.QWidget()
self.vlayout = QtWidgets.QVBoxLayout()
self.webview = QtWebEngineWidgets.QWebEngineView()
self.webview.setUrl(QUrl("https://www.youtube.com/embed/Ga3maNZ0x0w"))
self.vlayout.addWidget(self.webview)
self.centralwid.setLayout(self.vlayout)
This works perfectly with a normal youtube video, but when I try to play a live video, youtube gives the error "Your browser does not currently recognize any of the video formats available". I'm assuming this has to do with the format of live streams being different from normal videos (lives streams are in H.264), but I don't know how to resolve this. Please help!

Related

How to upload instant playable video to telegram

I am making a telegram bot to upload videos in my local PC. But when I sent the video, that message is very dumb. like this
Image 1
But I need videos like this
Image 2
Image 3
my code is
from pyrogram import Client
app = Client(
"session",
api_id=329,
api_hash="7943a36fdcf9"
)
with app:
app.send_video(chat_id = channel, video = 'vid.mp4',supports_streaming = True)
is there any specific specific methods for sending a proper video? How can I send a video properly
Your video file is too big. Telegram will handle videos < 10 MB and automatically create a thumbnail for you. For videos larger than that you'll have to supply the information about the video yourself. Resolution (width and height), length, thumbnail, etc..
Additionally, you can omit the supports_streaming argument, as Pyrogram defaults this to True anyway.
To get information about your video you could use something like ffprobe.
The docs show that you can add arguments caption and thumb to your call to send_video.

How to create a flash briefing using python OR Open a website and have the player playing as soon as page loads?

I am trying to create a voice assistant written in python. For voice assistants like Alexa or Google's voice assistant, when you ask "tell me the latest news" the app starts playing an audio file of the news. I found a similar type of file on the BBC's website (https://www.bbc.co.uk/news/av/10318236/headlines-from-bbc-news). I am trying to recreate this using python. I only see 2 options - one being to manipulate the BBC websites code and get the audio to play in python (without downloading an audio file) or the second being to open the BBC link above in an external browser (which I already know how to do) but have it so that the player plays as soon as the page opens.
Code to open website:
reg_ex = re.search('open website (.+)', command)
if reg_ex:
domain = reg_ex.group(1)
url = 'https://www.' + domain
webbrowser.open(url)
speak('Opening ' + url)
Thank you in advance to anyone that is able to help!
PS Keep in mind I'm a noobie at programming, so go easy on me :)

Screenshot of flash element in Python

How can I take a scrennshot of flash website in Python 3.5.1. I trying something like this but I can't see video image.
from selenium import webdriver
def webshot(url, filename):
browser = webdriver.PhantomJS()
browser.get(url)
browser.save_screenshot(filename)
browser.quit()
webshot('https://www.youtube.com/watch?v=YQHsXMglC9A', 'screentest.png')
Short version : With Youtube system, if you didn't press that "play" button (initiate playback) there is no video served. Loading the page via browser is a form of initiating playback too. However using a webshot doesn't fulfill Youtube server's requirements so it wont work.
long version :
How can I take a screenshot of a Flash website... I tried this but I
can't see video image.
webshot('https://www.youtube.com/watch?v=YQHsXMglC9A', 'screentest.png')
You cannot screenshot Youtube's video player content like this. The way Youtube works is that when video page is ready, another PHP file is accessed to determine the video link (eg: the correct file for chosen quality settings, etc). Basically you have to appear to be like a browser making an HTTP request to their servers. Their server gives temporary token to access video link until token expires etc. There's other issues like CORS to deal with. These things are not being done by your tool.
If only Youtube used a normal <video tag> with simple MP4 link then your code would've worked.
The best you can get is like below (see how there is no controls?) using :
webshot('https://www.youtube.com/embed/YQHsXMglC9A', 'screentest.png')

PopcornJS Youtube Player and Flask/Python

I'm trying to build a simple web application using PopcornJS in Python. I want to simply mute the volume of a youtube video and autoplay it but it seems to not be working/ there may be a bug in PopcornJS's youtube video player.
Here's my code:
<script>
var popcorn = Popcorn.youtube( "#video" , 'http://www.youtube.com/embed/XMW2lbNVaXY');
popcorn.volume(0);
popcorn.autoplay(true);
</script>
and the html
<div id="video"></div>
Seems like the volume control and the autoplay are not working. If I switch to a non youtube video everything works fine. Also if I look at my console during run time I see the following error
Blocked a frame with origin "http://www.youtube.com" from accessing
a frame with origin "http://127.0.0.1:5000". Protocols, domains,
and ports must match.
Googling the problem revealed that it might be a chrome bug, but I'm not sure. Anyone know what's wrong? Thanks!

Retrieve feed from a specific category with appengine python youtube api

http://code.google.com/apis/youtube/articles/youtube_api_appengine.html Following this tutorial I am able to retrive the most recent video feeds for my service.
feed = client.GetRecentlyFeaturedVideoFeed()
with the above command, I would like to retrieve videos for the four standar youtube categories news, comedy, sports, music so I guess I should query it somehow like:
feed = client.Query('http://gdata.youtube.com/feeds/api/videos/-/Comedy?v=2')
I am not able to figure out the syntax or even if I going the right direction.
It was quite simple in a similar post
feed = client.GetYouTubeVideoFeed('http://gdata.youtube.com/feeds/api/videos/-/Comedy?v=2')
and the relevant post: How to get the public channel URL from YouTubeVideoFeed object using the YouTube API?

Categories

Resources