Example #1
0
 def urlopen(self, req):
     self._socket_timeout = 600
     if isinstance(req, compat_basestring):
         req = sanitized_Request(req)
     opener = compat_urllib_request.build_opener()
     self._opener = opener
     return self._opener.open(req, timeout=self._socket_timeout)
Example #2
0
	def getVideoInfo(self,url):
		# General configuration
		tf=tempfile.NamedTemporaryFile(delete=False)
		tf.close()
		self.cookies=tf.name
		jar = compat_cookiejar.MozillaCookieJar(self.cookies)
		cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
		proxies = compat_urllib_request.getproxies()
		proxy_handler = compat_urllib_request.ProxyHandler(proxies)
		https_handler = make_HTTPS_handler(None)
		opener = compat_urllib_request.build_opener(https_handler, proxy_handler, cookie_processor, YoutubeDLHandler)
		compat_urllib_request.install_opener(opener)

		y=youtube_dl.YoutubeDL({'outtmpl':u'','skip_download':True, 'format_limit': 18}) # empty outtmpl needed due to weird issue in youtube-dl
		y.add_info_extractor(WatchCartoonOnlineIE())
		y.add_default_info_extractors()

		try:
			info=y.extract_info(url,download=False)
		except Exception:
			raise
			self.status='invalid'
			self.queue.removeMeAsync(self.uid) # Remove if possible
			self.ready.release()
			return False

		jar.save()

		if 'entries' in info:
			vinfo=info['entries'][0]
		else:
			vinfo=info

		if 'title' in vinfo:
			self.title=vinfo['title']
		if 'duration' in vinfo:
			self.duration=vinfo['duration']
		if 'extractor' in vinfo:
			self.site=vinfo['extractor']
		if 'url' in vinfo:
			self.media=vinfo['url']
		if 'thumbnail' in vinfo:
			self.thumbnail=vinfo['thumbnail']
		if 'description' in vinfo:
			self.description=vinfo['description']
		if 'id' in vinfo:
			self.vid=vinfo['id']

		if self.status=='added':
			self.status='ready'

		self.ready.release()
		return True
Example #3
0
    def get_video_info(self):
        url = self.url
        mimetype=get_mime_type(url)

        if mimetype.startswith("text/html"):
            params={}
            # General configuration
            tf=tempfile.NamedTemporaryFile(delete=False)
            tf.close()
            self.cookies=tf.name
            jar = compat_cookiejar.MozillaCookieJar(self.cookies)
            cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
            proxies = compat_urllib_request.getproxies()
            proxy_handler = compat_urllib_request.ProxyHandler(proxies)
            https_handler = make_HTTPS_handler(params)
            ydlh = YoutubeDLHandler(params)
            opener = compat_urllib_request.build_opener(https_handler, proxy_handler, cookie_processor, ydlh)
            compat_urllib_request.install_opener(opener)

            y=youtube_dl.YoutubeDL({'outtmpl':u'','skip_download':True}, auto_init=False) # empty outtmpl needed due to weird issue in youtube-dl
            y.add_info_extractor(WatchCartoonOnlineIE())
            y.add_default_info_extractors()

            try:
                info=y.extract_info(url,download=False)
            except Exception:
                raise
                self.status='invalid'
                self.queue.removeMeAsync(self.uid) # Remove if possible # TODO error here
                self.ready.release()
                return False

            jar.save()

            if 'entries' in info:
                vinfo=info['entries'][0]
            else:
                vinfo=info

            #import json
            #print json.dumps(vinfo, sort_keys=True,
            #                 indent=4, separators=(',', ': '))

            if 'title' in vinfo:
                self.title=vinfo['title']
            if 'duration' in vinfo:
                self.duration=vinfo['duration']
            if 'extractor' in vinfo:
                self.site=vinfo['extractor']
            if 'url' in vinfo:
                self.media=vinfo['url']
            else:
                if 'formats' in vinfo and len(vinfo['formats']) > 0:
                    best = vinfo['formats'][-1]
                    if 'url' in best:
                        self.media = best['url']
            if 'thumbnail' in vinfo:
                self.thumbnail=vinfo['thumbnail']
            if 'description' in vinfo:
                self.description=vinfo['description']
            if 'id' in vinfo:
                self.vid=vinfo['id']

        else:
            self.media=url
            self.title=url

        self.state_is_ready = True
        self.safe_update()
        return True
 def __init__(self, debuglevel=0):
     self._init_github_account()
     https_handler = make_HTTPS_handler({}, debuglevel=debuglevel)
     self._opener = compat_urllib_request.build_opener(https_handler)
 def __init__(self, debuglevel=0):
     self._init_github_account()
     https_handler = make_HTTPS_handler({}, debuglevel=debuglevel)
     self._opener = compat_urllib_request.build_opener(https_handler)
Example #6
0
    def get_video_info(self):
        url = self.url
        mimetype = get_mime_type(url)

        if mimetype.startswith("text/html"):
            params = {}
            # General configuration
            tf = tempfile.NamedTemporaryFile(delete=False)
            tf.close()
            self.cookies = tf.name
            jar = compat_cookiejar.MozillaCookieJar(self.cookies)
            cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
            proxies = compat_urllib_request.getproxies()
            proxy_handler = compat_urllib_request.ProxyHandler(proxies)
            https_handler = make_HTTPS_handler(params)
            ydlh = YoutubeDLHandler(params)
            opener = compat_urllib_request.build_opener(
                https_handler, proxy_handler, cookie_processor, ydlh)
            compat_urllib_request.install_opener(opener)

            y = youtube_dl.YoutubeDL(
                {
                    'outtmpl': u'',
                    'skip_download': True
                }, auto_init=False
            )  # empty outtmpl needed due to weird issue in youtube-dl
            y.add_info_extractor(WatchCartoonOnlineIE())
            y.add_default_info_extractors()

            try:
                info = y.extract_info(url, download=False)
            except Exception:
                raise
                self.status = 'invalid'
                self.queue.removeMeAsync(
                    self.uid)  # Remove if possible # TODO error here
                self.ready.release()
                return False

            jar.save()

            if 'entries' in info:
                vinfo = info['entries'][0]
            else:
                vinfo = info

            #import json
            #print json.dumps(vinfo, sort_keys=True,
            #                 indent=4, separators=(',', ': '))

            if 'title' in vinfo:
                self.title = vinfo['title']
            if 'duration' in vinfo:
                self.duration = vinfo['duration']
            if 'extractor' in vinfo:
                self.site = vinfo['extractor']
            if 'url' in vinfo:
                self.media = vinfo['url']
            else:
                if 'formats' in vinfo and len(vinfo['formats']) > 0:
                    best = vinfo['formats'][-1]
                    if 'url' in best:
                        self.media = best['url']
            if 'thumbnail' in vinfo:
                self.thumbnail = vinfo['thumbnail']
            if 'description' in vinfo:
                self.description = vinfo['description']
            if 'id' in vinfo:
                self.vid = vinfo['id']

        else:
            self.media = url
            self.title = url

        self.state_is_ready = True
        self.safe_update()
        return True