Questions tagged [pafy]

pafy is used to retrieve YouTube content such as video, audio, and metadata such as viewcount, duration, rating, author, resolution, bitrate, format, filesize, thumbnail, keywords, etc.

Features

  • Retrieve metadata such as viewcount, duration, rating, author, thumbnail, keywords
  • Download video or audio at requested resolution / bitrate / format / filesize
  • Command line tool (ytdl) for downloading directly from the command line
  • Retrieve the URL to stream the video in a player such as vlc or mplayer
  • Works with age-restricted videos and non-embeddable videos
  • Small, standalone, single importable module file (pafy.py)
  • Select highest quality stream for download or streaming
  • Download video only (no audio) in m4v or webm format
  • Download audio only (no video) in ogg or m4a format
  • Retrieve playlists and playlist metadata
  • Works with Python 2.6+ and 3.3+
  • Optionally depends on youtube-dl (recommended; more stable)

Full documentation is available at http://pythonhosted.org/pafy

91 questions
1
vote
2 answers

Python module installed properly but standard function not working in web2py

I am using Web2Py and want to use module pafy. so i first wrote the simple code in localhost which was import pafy video = pafy.new("Here i wrote the URL of the youtube video which i want to get") this is working in localhost but in pythonanywhere…
Tushar Yadav
  • 103
  • 1
  • 9
1
vote
0 answers

Python streaming with mplayer

Hey everyone this is my first question so I apologize for any formatting errors/ignorance. I'm working on a personal assistant and I want it to stream youtube videos (audio only). I've managed to get it to find the url of the first video of a…
0
votes
0 answers

vlc player: Pause button when clicked give error: avcodec decoder error: hardware acceleration picture allocation failed

I am new to python and trying to create GUI that take in user inout of video's name and play it in the frame of said GUI, when pasuse button click it show the error below. [0000019acb774fe0] avcodec decoder error: hardware acceleration picture…
0
votes
1 answer

Getting Youtube Audio Stream with yt_dlp, NOT using pafy

I have made a GUI youtube audio player. It uses pafy, a library that gets the stream-urls of a given youtube url. This is wonderful, but pafy has 2 problems; one is that it, since at least half a year, has an error because it tries to get the…
0
votes
1 answer

Pafy+Youtub_dl+OpenCV is slow to display videos

I am trying a basic example of displaying a youtube video using opencv, and I seem to get 50% or less of the framerate as in the browser. Eventually I want to make a real-time computer vision application from youtube streams (well, a fixed delay is…
user2460953
  • 319
  • 1
  • 3
  • 10
0
votes
0 answers

How can I get YouTube Download Video link with Pafy?

Pafy gives me a link to download some file that is not related to the video itself. I want to get a link to download the video. My code: video = pafy.new(url) video.videostreams stream = video.videostreams[0] print(stream.url)
shp190
  • 1
  • 1
0
votes
2 answers

python pafy youtube to mp3 error, KeyError: 'dislike_count'

this is my code it is very simple: import pafy link = input("paste youtube link: ") video = pafy.new(link) bestaudio = video.getbestaudio() print(video.title) bestaudio.download() and this is the error: Traceback (most recent call last): File…
0
votes
1 answer

dislike_count with pafy and youtube_dl

I have a code for a discord bot that plays music in voice channels and since youtube removed the dislike counter on video i get an error nextcord.errors.ApplicationInvokeError: Command raised an exception: KeyError: 'dislike_count' I tried to…
0
votes
0 answers

Using Pafy.published raises an error instead of replying with the publish date of the video

Code: import pafy video = pafy.new("https://www.youtube.com/watch?v=dQw4w9WgXcQ") try: print(video.published) except pafy.util.GdataError as e: print(e) Output: Youtube Error 403: The request cannot be completed because you have exceeded…
Sandy
  • 247
  • 3
  • 12
0
votes
0 answers

Youtube-dl code error pafy line 1892 in call

CODE: class CallWrapper: """Internal class. Stores function to call when some user defined Tcl function is called e.g. after an event occurred.""" def __init__(self, func, subst, widget): """Store FUNC, SUBST and WIDGET as…
Python
  • 1
0
votes
1 answer

Stopping python-vlc: player.stop() doesn't work

I am trying to play a youtube video using pafy and vlc: def run(command, args, voice_instance): if command == "pune": search_query = " ".join(args) result = YoutubeSearch(search_query, max_results=10).to_dict()[0] …
0
votes
1 answer

I close vlc media, but after this audio remains and i can't use gui

When I close the video with a cross, the audio remains. I use pafy and vlc. Also i can't close PyQt app after closing video. I use python 3.8. import sys import pafy import vlc from PyQt5.QtWidgets import QApplication, QDialog, QLabel, QHBoxLayout,…
0
votes
1 answer

Multi threading with pafy

I'm trying to use multi threading over multiple pafy instances to fetch a number of video streams. Simplified version of my code: import pafy import threading def get_playurl(url): video = pafy.new(url) best = video.getbest() playurl =…
michael
  • 5
  • 1
0
votes
1 answer

problem with window.read() and time.sleep() when playing an mp3 in python

I'm making a program with pafy, vlc, PySimpleGUI that takes a youtube url and plays it as mp3 the problem I got when I first tried the console mode is that the mp3 stops after a while and I fixed it with time.sleep(seconds) and now everything works…
YASSINE
  • 100
  • 1
  • 5
0
votes
1 answer

Python stream audio from YouTube livestream

I'm interested in creating a python 3.9 program that streams audio from a YouTube livestream but unfortunately I can't get the video.getbestaudio() function to work and the function only returns the value null. Thus causing the null error on the…
Stub
  • 1
  • 2