Search code examples
pythonyoutube-dl

Printing within a class method in python does not work


I am trying to learn how to add support to a new website in youtube dl from this website I modified it because the website is outdated. The following is my code

from .common import InfoExtractor

class VineIE(InfoExtractor):
    _VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        print(webpage)
        return []

My intention is to debug and print variables and see what is happening. So I try running it

python -m youtube_dl vine.co/v/b9KOOWX7HUx

However, I do not get the webpage variable in the console. What I get instead is?

[generic] b9KOOWX7HUx: Requesting header
WARNING: Falling back on generic information extractor.
[generic] b9KOOWX7HUx: Downloading webpage
[generic] b9KOOWX7HUx: Extracting information
ERROR: Unsupported URL: http://www.vine.co/v/b9KOOWX7HUx

Why does not the print function work?


Solution

  • youtube-dl already has a VineIE. You should edit that extractor instead of writing a new one.

    In any case, your code is most likely not executed. In extractors.py, import it, by adding a line like

    from vine import VineIE
    

    Again, note that your actual extractor cannot be called VineIE, because such an extractor exists already.

    For more information on how to create an extractor, please follow the official documentation on how to create a youtube-dl extractor.