def __init__(self, f, f_audio, info, session, referer, cw=None): self.f_audio = f_audio self.cw = cw self.title = title = info['title'] self.id = info['id'] self.url = f['url'] self.artist = info.get('uploader') self.header = utils.capitalize(get_ie_key(info)) self.session = session self.referer = referer self.url_thumb = info.get('thumbnail') self.thumb = BytesIO() if self.url_thumb: downloader.download(self.url_thumb, referer=referer, buffer=self.thumb, session=session) ext = get_ext_(self.url, session, referer) if not ext: print('empty ext') if f['_resolution']: ext = '.mp4' else: ext = '.mp3' if ext.lower() == '.m3u8': try: url = playlist2stream(self.url, referer, session=session, n_thread=4) except: url = M3u8_stream(self.url, referer=referer, session=session, n_thread=4) ext = '.mp4' else: url = self.url self.url = LazyUrl(referer, lambda x: url, self, pp=self.pp) self.filename = format_filename(title, self.id, ext, header=self.header)
def _get_stream(url_m3u8): print('_get_stream', url_m3u8) try: stream = playlist2stream(url_m3u8) except Exception as e: print(e) stream = M3u8_stream(url_m3u8) return stream
def __init__(self, url): try: m = playlist2stream(url) except: m = M3u8_stream(url) self.url = LazyUrl(url, lambda _: m, self) self.title = os.path.splitext(os.path.basename(url))[0] self.filename = clean_title(self.title, n=-4) + '.mp4'
def __init__(self, url, n_thread): try: m = playlist2stream(url, n_thread=n_thread) except: m = M3u8_stream(url, n_thread=n_thread) self.url = LazyUrl(url, lambda _: m, self) self.title = os.path.splitext(os.path.basename(url))[0] self.id_ = md5(url.encode('utf8')).hexdigest()[:8] tail = ' ({}).mp4'.format(self.id_) self.filename = clean_title(self.title, n=-len(tail)) + tail
def get_video(url_page): id = get_id(url_page) html = downloader.read_html(url_page) soup = Soup(html, unescape=True) name = soup.find('title').text.replace('- XVIDEOS.COM', '').strip() print('name:', name) url = re.find('.setVideoHLS\\([\'"](.+?)[\'"]\\)', html) print(url) ext = os.path.splitext(url.split('?')[0])[1] if ext.lower() == '.m3u8': url = playlist2stream(url, n_thread=5) url_thumb = soup.find('meta', {'property': 'og:image'}).attrs['content'] video = Video(url, url_page, id, name, url_thumb) return video
def get(self, url_page): if not self._url: id = get_id(url_page) html = downloader.read_html(url_page) soup = Soup(html, unescape=True) self.title = soup.find('title').text.replace('- XVIDEOS.COM', '').strip() url = re.find(r'''.setVideoHLS\(['"](.+?)['"]\)''', html) ext = get_ext(url) if ext.lower() == '.m3u8': url = playlist2stream(url, n_thread=5) url_thumb = soup.find('meta', {'property': 'og:image'}).attrs['content'] self.thumb = BytesIO() downloader.download(url_thumb, buffer=self.thumb) self.filename = format_filename(self.title, id, '.mp4') self._url= url return self._url
def __init__(self, id_, title, url, url_thumb): self.id_ = id_ self.title = clean_title('{}'.format(title)) self.url = url ext = get_ext(self.url) if ext.lower() == '.m3u8': try: self.url = playlist2stream(self.url, n_thread=4) except: self.url = M3u8_stream(self.url, n_thread=4) self.url_thumb = url_thumb self.thumb = BytesIO() downloader.download(self.url_thumb, buffer=self.thumb) if ext.lower() == '.m3u8': ext = '.mp4' self.filename = format_filename(self.title, self.id_, ext) print('filename:', self.filename)
def get_video(url): html = downloader.read_html(url) soup = Soup(html) for script in soup.findAll('script'): script = script.text or script.string or '' hls = re.find(r'''html5player\.setVideoHLS\(['"](.+?)['"]''', script) if hls: break else: raise Exception('No VideoHLS') video = playlist2stream(hls) title = get_title(soup) url_thumb = soup.find('meta', {'property': 'og:image'}).attrs['content'].strip() video = Video(video, url, title, url_thumb) return video
def _get(self, url_page): id = get_id(url_page) html = downloader.read_html(url_page) soup = Soup(html) self.title = html_unescape(soup.find('title').text).replace( '- XVIDEOS.COM', '').strip() url = re.find(r'''.setVideoHLS\(['"](.+?)['"]\)''', html) or re.find( r'''.setVideoUrlHigh\(['"](.+?)['"]\)''', html) or re.find( r'''.setVideoUrlLow\(['"](.+?)['"]\)''', html) #https://www.xvideos.com/video65390539/party_night if not url: raise Exception('no video url') ext = get_ext(url) if ext.lower() == '.m3u8': url = playlist2stream(url, n_thread=5, res=get_resolution()) #4773 self.url_thumb = soup.find('meta', { 'property': 'og:image' }).attrs['content'] self.filename = format_filename(self.title, id, '.mp4') self._url = url
def __init__(self, img): self.id = img['id'] print(self.id) videos = img.get('videos') if videos and 'video_list' in videos: src = list(videos['video_list'].values())[0]['url'] else: src = img['images']['orig']['url'] ext = get_ext(src) if ext.lower() == '.m3u8': try: src = playlist2stream(src) except: src = M3u8_stream(src) ext = '.mp4' self.url = LazyUrl(('{}/pin/{}/').format(BASE_URL, self.id), lambda _: src, self) self.filename = ('{}{}').format(self.id, ext)