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
2
votes
1 answer

Play a downloaded video with flask

I have a simple flask server. I downloaded, using pafy, a video from a youtube link provided by the user. @app.route('/') def download(): return render_template('basic.html') The basic.html template has a form that submits an action to…
RandomGuyqwert
  • 425
  • 6
  • 18
2
votes
2 answers

How to connect node.js app with python script?

I've node app in Meteor.js and short python script using Pafy. import pafy url = "https://www.youtube.com/watch?v=AVQpGI6Tq0o" video = pafy.new(url) allstreams = video.allstreams for s in allstreams: print(s.mediatype, s.extension,…
mhlavacka
  • 691
  • 11
  • 25
2
votes
1 answer

Admin is disabled because insecure channel

I am using web2py in pythonanywhere.com for creating my webapp but when i import the module name pafy and using it in controllers of web2py and then running my app it shows Admin is disabled because insecure channel. Code which i wrote there is…
Tushar Yadav
  • 103
  • 1
  • 9
2
votes
0 answers

Python socket hangs my code on internet disconnect

Hey everyone! I'm using a python module called pafy which allows me to get data from youtube. While I was using this, my internet had disconnected at a certain time which didn't give an error response but hung my program. When I reconnected the…
Johnny
  • 127
  • 1
  • 11
2
votes
0 answers

Running python script after 2-5 times (random) gives me error (will work again if I restart the django server!)

let's say I created a basic web for converting youtube videos to gifs this is my views in django code from django.shortcuts import render from django.http import HttpResponse from django.template import RequestContext from django.shortcuts import…
1
vote
1 answer

Pafy module causing error in PythonAnywhere

I am using pafy in a Flask app. It is working fine on my local machine. But when I am trying to deploy and run on PythonAnywhere, it is throwing an error. Upon execution, it is showing the following ewrror: youtube_dl.utils.ExtractorError: Unable…
Phil
  • 21
  • 3
1
vote
0 answers

How to process audio from Youtube live stream video using Python?

I have tried several methods to extract audio from live youtube stream video, but they didn't work. I have tried the following snippets. import youtube_dl import wave def process_audio(chunk): # Process the audio data in the chunk …
KHIZER
  • 21
  • 4
1
vote
0 answers

Update tqdm bar

I'm creating a small script for me to download youtube videos sounds. Everytime you download a sound i use a tqdm bar to display download infos. The first time you download everything work fine, but the second time my bar is completely destroyed :(.…
Zartox29
  • 81
  • 8
1
vote
0 answers

Youtube playlist is unrecognized

Im trying to set a radio and youtube playlist player my code works with radio and single youtube link but with playlist it says that the link is unrecognized, can somoene help? import os from os import path from random import randrange from…
ralphgz
  • 23
  • 7
1
vote
1 answer

Pafy Youtube Error 403 when converting video

I'm getting this error when converting a video using pafy GdataError at / Youtube Error 403: The request cannot be completed because you have exceeded your quota. This is my code (views.py): def…
FLYAX
  • 141
  • 12
1
vote
2 answers

How to read Youtube Videos with OpenCV at specific timestamps and set duration without downloading it?

I have tried using pafy but it plays the video from beginning, I want to run my model on specific parts of the video. If this is possible please guide me how to do it. Any help is appreciated, thanks in advance :)
Atharva Katre
  • 457
  • 1
  • 6
  • 17
1
vote
1 answer

Setting a certain location when using pafy

This is my code: import pafy url = "youtube_url_here" vid = pafy.new(url) reso = vid.getbest() reso.download() Could anyone tell me how to set a location to save the video in instead of the working directory?, also how to make the program ask me…
LastFox
  • 31
  • 3
1
vote
2 answers

No module named pafy

I have installed 'pafy' using pip, when I run this code: import pafy url = 'https://www.youtube.com/watch?v=evzcGBdEMTQ&ab_channel=orbitron' dvideo = pafy.new(url) reso = dvideo.getbest() reso.download() it gives me this error: No module named…
Last _Fox
  • 13
  • 4
1
vote
1 answer

in pafy i got that error " best.resolution, best.extension(res, format) TypeError: 'str' object is not callable"

from pafy import * url = str(input("Videonun Youtube linkini girin")) video = pafy.new(url) streams = video.streams for s in streams: print(s.resolution, s.extension, s.get_filesize(), s.url) format = input("indirilecek turu seçin") res =…
1
vote
0 answers

Pafy cannot read YouTube video as 'webm'

I'm trying to use cv2 to process YouTube videos downloaded from Pafy, but whenever I try to use the format 'webm', the getbest() always returns a 'NoneType'. Any idea why or how to fix it? Thanks. AttributeError Traceback…
Astra
  • 11
  • 1