当前位置: 首页>>代码示例>>Python>>正文


Python YoutubeDL.add_default_info_extractors方法代码示例

本文整理汇总了Python中youtube_dl.YoutubeDL.add_default_info_extractors方法的典型用法代码示例。如果您正苦于以下问题:Python YoutubeDL.add_default_info_extractors方法的具体用法?Python YoutubeDL.add_default_info_extractors怎么用?Python YoutubeDL.add_default_info_extractors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在youtube_dl.YoutubeDL的用法示例。


在下文中一共展示了YoutubeDL.add_default_info_extractors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: YoutubeDLWrapper

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
class YoutubeDLWrapper(object):
    """ Used to wrap youtubedl import, since youtubedl currently overrides
    global HTMLParser.locatestarttagend regex with a different regex
    that doesn't quite work.

    This wrapper ensures that this regex is only set for YoutubeDL and unset
    otherwise
    """
    def __init__(self):
        import HTMLParser as htmlparser
        self.htmlparser = htmlparser

        self.orig_tagregex = htmlparser.locatestarttagend

        from youtube_dl import YoutubeDL as YoutubeDL

        self.ydl_tagregex = htmlparser.locatestarttagend

        htmlparser.locatestarttagend = self.orig_tagregex

        self.ydl = YoutubeDL(dict(simulate=True,
                                  youtube_include_dash_manifest=False))
        self.ydl.add_default_info_extractors()

    def extract_info(self, url):
        info = None
        try:
            self.htmlparser.locatestarttagend = self.ydl_tagregex
            info = self.ydl.extract_info(url)
        finally:
            self.htmlparser.locatestarttagend = self.orig_tagregex

        return info
开发者ID:akeprojecta,项目名称:pywb,代码行数:35,代码来源:live_rewrite_handler.py

示例2: DownloadProcess

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
class DownloadProcess(multiprocessing.Process):
    """
    Actual download process which calls youtube-dl. You should never need to interact with this directly.
    """

    def __init__(self, url, status_queue, output_writer):
        super(DownloadProcess, self).__init__()

        self.url = url
        self.status_queue = status_queue

        self.info = {}

        sys.stdout = output_writer
        sys.stderr = output_writer

        self.downloader = YoutubeDL({"progress_hooks": [self.update_status]})
        self.downloader.add_default_info_extractors()

    def update_status(self, status):
        self.status_queue.put(status)

    def run(self):
        self.info = self.downloader.extract_info(self.url)

    def stop(self):
        # Kill any child processes that may have spawned (e.g. ffmpeg)
        import psutil, signal

        s = psutil.Process()
        for child in s.children(recursive=True):
            child.send_signal(signal.SIGINT)
开发者ID:computerfreak,项目名称:video-archiver,代码行数:34,代码来源:archiver.py

示例3: get_video_url

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
def get_video_url(params):
    """Get video URL and start video player"""
    url_selected = ''
    all_datas_videos_quality = []
    all_datas_videos_path = []
    videos_html = utils.get_webcontent(params.video_url)
    videos_soup = bs(videos_html, 'html.parser')

    list_videos = videos_soup.find(
        'ul', class_='nav nav-tabs').find_all('a')

    for video in list_videos:
        if '#video-' in video.get('href'):
            # Find a better solution to strip
            all_datas_videos_quality.append(video.get_text().strip())
            # Get link
            value_jwplayer_id = video.get('data-jwplayer-id')
            # Case mp4
            if value_jwplayer_id != '':
                list_streams = videos_soup.find_all(
                    'div', class_='jwplayer')
                for stream in list_streams:
                    if stream.get('id') == value_jwplayer_id:
                        url = stream.get('data-source')
            # Cas Yt
            else:
                video_id = re.compile(
                    'youtube.com/embed/(.*?)\?').findall(videos_html)[0]
                url = resolver.get_stream_youtube(video_id, False)
            all_datas_videos_path.append(url)
        # Get link from FranceTV
        elif '#ftv-player-' in video.get('href'):
            # Find a better solution to strip
            all_datas_videos_quality.append(video.get_text().strip())
            # Get link
            value_ftvlayer_id = video.get('data-ftvplayer-id')
            list_streams = videos_soup.find_all(
                'iframe', class_='embed-responsive-item')
            for stream in list_streams:
                if stream.get('id') == value_ftvlayer_id:
                    url_id = stream.get('src')
            ydl = YoutubeDL()
            ydl.add_default_info_extractors()
            with ydl:
                result = ydl.extract_info(
                    url_id, download=False)
                for format_video in result['formats']:
                    url = format_video['url']
            all_datas_videos_path.append(url)

    if len(all_datas_videos_quality) > 1:
        seleted_item = common.sp.xbmcgui.Dialog().select(
            common.GETTEXT('Choose video quality'),
            all_datas_videos_quality)
        if seleted_item == -1:
            return ''
        url_selected = all_datas_videos_path[seleted_item]
        return url_selected
    else:
        return all_datas_videos_path[0]
开发者ID:Lunatixz,项目名称:repo-plugins,代码行数:62,代码来源:taratata.py

示例4: ScramDLThread

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
class ScramDLThread(threading.Thread):
    def __init__(self,  urls, addendum_params=None):
        threading.Thread.__init__(self)

        override_params = dict()
        override_params['writeinfojson'] = False
        override_params['test'] = False
        override_params['format'] = 'mp4'
        if addendum_params is not None:
            override_params.update(addendum_params)

        params = get_params(override_params)
        self.scram_dl = YoutubeDL(params)
        self.scram_dl.add_progress_hook(self.hook_progress)
        self.scram_dl.add_default_info_extractors()
        self.is_finished = False
        self.urls = urls

    def hook_progress(self, status):
        if status['status'] == 'finished':
            self.is_finished = True
        else:
            self.is_finished = False

    def run(self):
        self.scram_dl.download(self.urls)
开发者ID:oDeskJobs,项目名称:youtube-dl,代码行数:28,代码来源:scram_dl_monitoring.py

示例5: PyJizzParser

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
class PyJizzParser(object):
	def __init__(self, model):
		self.model = model
		self.model.parser = self
		self.ydl = YoutubeDL()
		self.ydl.add_default_info_extractors()
		
	def parseCategories(self):
		c = PornHubCategoryParser(self.model)
		c.run()
	
	def parseCategoryPage(self, category, page = 1):
		if page == 0 or page == 1:
			url = self.model.categories_url[category]
		else:
			url = "{site}{page_url}{page}".format(
				site = self.model.site,
				page_url = self.model.porn[category]['page_url'],
				page = page)
		print("page parser creating for page", page)
		p = PornHubPageParser(self.model, url, category, page)
		p.run()
		print("page parser exit for page", page)
		
	def getInfo(self, vkey):
		info = self.ydl.extract_info('http://www.pornhub.com/view_video.php?viewkey={v}'.format(v = vkey), download=False)
		return info
开发者ID:RussianBruteForce,项目名称:PyJizz,代码行数:29,代码来源:parser.py

示例6: process_url

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
    def process_url(self, source, global_opts):
        """Main method for processing urls

        This method basically hands over the configuration to YoutubeDL and repeats
        the step until every source in the configuration was read
        """

        ydl = YoutubeDL()
        ydl.add_default_info_extractors()

        sourceUrl = source['url']

        sourceDescription = source.get("description", "")

        self._logsource(
            "Processing source: '" + sourceDescription +
            "' Url: '" + sourceUrl + "'", source)

        # Merge local parameters with global ones
        ydl.params = copy.copy(global_opts)
        ydl.params.update(source)

        prefix = ""

        ydl.params['match_filter'] = (
            None if 'match_filter' not in ydl.params or ydl.params['match_filter'] is None
            else match_filter_func(ydl.params['match_filter']))

        # Settings by commute tube over the standard settings, respect if the config sets them differently
        if 'format' not in ydl.params and 'format_limit' not in ydl.params:
            ydl.params['format'] = "bestvideo+bestaudio/best" if 'format' not in self.config else self.config["format"]
        if 'nooverwrites' not in ydl.params:
            ydl.params['nooverwrites'] = True
        if 'ignoreerrors' not in ydl.params:
            ydl.params['ignoreerrors'] = True
        if 'download_archive' not in ydl.params:
            ydl.params['download_archive'] = self.download_archive
        if 'prefix' in ydl.params:
            prefix = ydl.params['prefix']

        ydl.params['restrictfilenames'] = True
        ydl.params['logger'] = self.ydlLog

        outtmpl = self.pathToDownloadFolder + "/" + prefix + \
            '%(uploader)s-%(title)s.%(ext)s'

        if 'outtmpl' not in ydl.params:
            ydl.params['outtmpl'] = outtmpl
        elif not (ydl.params['outtmpl'].startswith(self.pathToDownloadFolder)):
            self._logsource("Prefixing custom set outtmpl with '" + self.pathToDownloadFolder + "/" + prefix + "'", source)
            ydl.params['outtmpl'] = self.pathToDownloadFolder + "/" + prefix + \
                ydl.params['outtmpl']

        if self.debug:
            self._logsource(
                "All downloads will be simulated since this is debug mode", source)
            ydl.params['simulate'] = True

        ydl.download([source['url']])
开发者ID:snipem,项目名称:commute-tube,代码行数:61,代码来源:commute_tube.py

示例7: get_info

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
def get_info(url):
    ydl = YoutubeDL({
        'forceurl': True,
        'quiet': True
    })

    ydl.add_default_info_extractors()
    return ydl.extract_info(url, download=False)
开发者ID:ceari,项目名称:mpd_youtube_proxy,代码行数:10,代码来源:mpd_youtube.py

示例8: get_youtube_info

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
def get_youtube_info(url):
    ydl = YoutubeDL()
    ydl.add_default_info_extractors()
    try:
        info = ydl.extract_info(url, download=False)
    except:
        return None
    return info
开发者ID:suBDavis,项目名称:hatchJukebox,代码行数:10,代码来源:jukebox.py

示例9: download

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
def download(link, files_present, avg):
    '''gets the playlist and Downloads the videos that i dont have'''

    #url = 'https://www.youtube.com/watch?v=MCs5OvhV9S4'
    url = 'https://www.youtube.com/playlist?list=PLwyG5wA5gIzjhW36BxGBoQwUZHnPDFux3'
    ydl=YoutubeDL()
    ydl.add_default_info_extractors()
    playlist = ydl.extract_info(url, download=False)
    for video in playlist['entries']:
        import ipdb; ipdb.set_trace()
        if video['title'] in files_present:
            print ("Video #{} {} is present and will be ignored").format(video['playlist_index'], video['title'])
        else:
            print   ("currently downloading: {}").format(video['title'])
            ydl.download(video['webpage_url'])
开发者ID:Murima,项目名称:Random-scripts,代码行数:17,代码来源:pycon.py

示例10: download_youtube

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
def download_youtube(url,filepath,params=None):
    tmp_filepath = compat_str(filepath)
    print "download to",tmp_filepath
    params = params or settings.youtube_params
    params.update({"outtmpl":tmp_filepath,"daterange":DateRange(None,None)})
    y = YoutubeDL(params) 
     #y = YoutubeDL({"format":"18/34/35/5/17","outtmpl":filepath}) 
     #y.print_debug_header()
    y.add_default_info_extractors()
    y.add_post_processor(FFmpegExtractAudioPP(preferredcodec="m4a",preferredquality=5, nopostoverwrites=False))
    value = y.download([url])
    #cmd = 'youtube-dl {url} --extract-audio --audio-format wav -o {filepath}'.format(url=url,filepath=filepath)
    #print cmd
    #result = subprocess.call(cmd,shell=True)
    #print result
    return True
开发者ID:nod3x,项目名称:playmuzik,代码行数:18,代码来源:muzik.py

示例11: VideoLoader

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
class VideoLoader(BaseLoader):
    CONTENT_TYPE = 'application/vnd.youtube-dl_formats+json'

    def __init__(self):
        try:
            from youtube_dl import YoutubeDL as YoutubeDL
        except ImportError:
            self.ydl = None
            return

        self.ydl = YoutubeDL(dict(simulate=True,
                                  youtube_include_dash_manifest=False))

        self.ydl.add_default_info_extractors()

    def load_resource(self, cdx, params):
        load_url = cdx.get('load_url')
        if not load_url:
            return None

        if params.get('content_type') != self.CONTENT_TYPE:
            return None

        if not self.ydl:
            return None

        info = self.ydl.extract_info(load_url)
        info_buff = json.dumps(info)
        info_buff = info_buff.encode('utf-8')

        warc_headers = {}

        schema, rest = load_url.split('://', 1)
        target_url = 'metadata://' + rest

        dt = timestamp_to_datetime(cdx['timestamp'])

        warc_headers['WARC-Type'] = 'metadata'
        warc_headers['WARC-Record-ID'] = self._make_warc_id()
        warc_headers['WARC-Target-URI'] = target_url
        warc_headers['WARC-Date'] = datetime_to_iso_date(dt)
        warc_headers['Content-Type'] = self.CONTENT_TYPE
        warc_headers['Content-Length'] = str(len(info_buff))

        warc_headers = StatusAndHeaders('WARC/1.0', warc_headers.items())

        return warc_headers, None, BytesIO(info_buff)
开发者ID:ikreymer,项目名称:webrec-platform,代码行数:49,代码来源:responseloader.py

示例12: on_task_output

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
    def on_task_output(self, task, config):
        import youtube_dl.YoutubeDL
        from youtube_dl.utils import ExtractorError

        class YoutubeDL(youtube_dl.YoutubeDL):
            def __init__(self, *args, **kwargs):
                self.to_stderr = self.to_screen
                self.processed_info_dicts = []
                super(YoutubeDL, self).__init__(*args, **kwargs)

            def report_warning(self, message):
                raise ExtractorError(message)

            def process_info(self, info_dict):
                self.processed_info_dicts.append(info_dict)
                return super(YoutubeDL, self).process_info(info_dict)
        for entry in task.accepted:
            if task.options.test:
                log.info('Would download %s' % entry['title'])
            else:
                try:
                    outtmpl = entry.render(config['path']) + '/' + pathscrub(entry.render(config['template']) + '.%(ext)s', filename=True)
                    log.info("Output file: %s" % outtmpl)
                except RenderError as e:
                    log.error('Error setting output file: %s' % e)
                    entry.fail('Error setting output file: %s' % e)
                params = {'quiet': True, 'outtmpl': outtmpl}
                if 'username' in config and 'password' in config:
                    params.update({'username': config['username'], 'password': config['password']})
                elif 'username' in config or 'password' in config:
                    log.error('Both username and password is required')
                if 'videopassword' in config:
                    params.update({'videopassword': config['videopassword']})
                if 'title' in config:
                    params.update({'title': config['title']})
                ydl = YoutubeDL(params)
                ydl.add_default_info_extractors()
                log.info('Downloading %s' % entry['title'])
                try:
                    ydl.download([entry['url']])
                except ExtractorError as e:
                    log.error('Youtube-DL was unable to download the video. Error message %s' % e.message)
                    entry.fail('Youtube-DL was unable to download the video. Error message %s' % e.message)
                except Exception as e:
                    log.error('Youtube-DL failed. Error message %s' % e.message)
                    entry.fail('Youtube-DL failed. Error message %s' % e.message)
开发者ID:z00nx,项目名称:flexget-plugins,代码行数:48,代码来源:youtubedl.py

示例13: _download_restricted

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
def _download_restricted(url, filename, age):
    """ Returns true iff the file has been downloaded """

    params = {
        'age_limit': age,
        'skip_download': True,
        'writeinfojson': True,
        "outtmpl": "%(id)s.%(ext)s",
    }
    ydl = YoutubeDL(params)
    ydl.add_default_info_extractors()
    json_filename = filename + '.info.json'
    try_rm(json_filename)
    ydl.download([url])
    res = os.path.exists(json_filename)
    try_rm(json_filename)
    return res
开发者ID:alienkainan,项目名称:youtube-dl,代码行数:19,代码来源:test_age_restriction.py

示例14: __init__

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
    def __init__(self, dl_id, url):
        self.dl_id = dl_id
        self.url = url

        self.start_time = datetime.datetime.utcnow()

        self.download_proc = None

        self.status_queue = multiprocessing.Queue()
        self.status = {}

        self.child_output = OutputWriter()
        self.log = ""

        info_downloader = YoutubeDL({"quiet": True})
        info_downloader.add_default_info_extractors()

        self.info = info_downloader.extract_info(self.url, download=False)
开发者ID:computerfreak,项目名称:video-archiver,代码行数:20,代码来源:archiver.py

示例15: processUrl

# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import add_default_info_extractors [as 别名]
    def processUrl(self, source):

        ydl = YoutubeDL()
        ydl.add_default_info_extractors()

        sourceUrl = source['url'].decode()
        sourceDescription = ""

        if 'description' in source:
            sourceDescription = source['description'].decode()

        self.log.info(
            "Processing source: '" + sourceDescription
            + "' Url: '" + sourceUrl + "'")

        ydl.params = source
        prefix = ""

        if 'format' not in ydl.params and 'format_limit' not in ydl.params:
            ydl.params['format'] = "bestvideo+bestaudio"
        if 'nooverwrites' not in ydl.params:
            ydl.params['nooverwrites'] = True
        if 'ignoreerrors' not in ydl.params:
            ydl.params['ignoreerrors'] = True
        if 'download_archive' not in ydl.params:
            ydl.params['download_archive'] = "already_downloaded.txt"
        if 'prefix' in ydl.params:
            prefix = ydl.params['prefix']

        ydl.params['restrictfilenames'] = True
        ydl.params['logger'] = self.ydlLog

        outtmpl = self.pathToDownloadFolder + "/" + prefix + \
            u'%(uploader)s-%(title)s-%(id)s.%(ext)s'
        if 'outtmpl' not in ydl.params:
            ydl.params['outtmpl'] = outtmpl

        if self.debug is True:
            self.log.debug(
                "All downloads will be simulated since this is debug mode")
            ydl.params['simulate'] = True

        ydl.download([source['url']])
开发者ID:ohhdemgirls,项目名称:commute-tube,代码行数:45,代码来源:commute_tube.py


注:本文中的youtube_dl.YoutubeDL.add_default_info_extractors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。