mps-youtube / pafy

Python library to download YouTube content and retrieve metadata
1.39k stars 313 forks source link

License attribute on the Pafy object #182

Open z opened 7 years ago

z commented 7 years ago

It looks like cc_license is supported in the playlist_meta [1], but I don't see an attribute for .license per video.

This value is supported by youtube-dl's output template:

% youtube-dl --get-filename -o '%(title)s - %(license)s.%(ext)s' BaW_jenozKc --restrict-filenames
youtube-dl_test_video_a - Standard_YouTube_License.mp4

Can this be exposed as an attribute on the Pafy object for a single video?

z commented 7 years ago

My temporary work around:

import subprocess

# Work around to get license information until https://github.com/mps-youtube/pafy/issues/182
process = subprocess.Popen(['youtube-dl', '--get-filename', '-o', '%(license)s', youtube_url], stdout=subprocess.PIPE)
out, err = process.communicate()
if out:
    video_license = out.decode("utf-8").strip()