1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-26 00:07:55 +01:00

Changes to close pending fixes.

Changes done to close pending fixes raised by youtube_dl maintainer.
This commit is contained in:
nindogo 2019-06-24 04:25:30 +03:00
parent d02cc2bf50
commit fe2344fd8e

View File

@ -11,6 +11,7 @@ from ..utils import (
class PornTrexBaseIE(InfoExtractor): class PornTrexBaseIE(InfoExtractor):
_NETRC_MACHINE = 'porntrex'
def _login(self): def _login(self):
username, password = self._get_login_info() username, password = self._get_login_info()
@ -23,9 +24,9 @@ class PornTrexBaseIE(InfoExtractor):
login_form = self._hidden_inputs(login_page) login_form = self._hidden_inputs(login_page)
login_form.update({ login_form.update({
'username': username.encode('utf-8'), 'username': username,
'pass': password.encode('utf-8'), 'pass': password,
'remember_me': str(1).encode('utf-8'), 'remember_me': 1,
}) })
login_page = self._download_webpage( login_page = self._download_webpage(
@ -43,7 +44,6 @@ class PornTrexBaseIE(InfoExtractor):
class PornTrexIE(PornTrexBaseIE): class PornTrexIE(PornTrexBaseIE):
_NETRC_MACHINE = 'porntrex'
_VALID_URL = r'https?://(?:www\.)?porntrex\.com/video/(?P<id>[0-9]+)/' _VALID_URL = r'https?://(?:www\.)?porntrex\.com/video/(?P<id>[0-9]+)/'
_TEST = { _TEST = {
'url': 'https://www.porntrex.com/video/311136/naomi-gets-fingered-before-the-fucking', 'url': 'https://www.porntrex.com/video/311136/naomi-gets-fingered-before-the-fucking',
@ -61,28 +61,36 @@ class PornTrexIE(PornTrexBaseIE):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
self.report_extraction(video_id) # print(self._html_search_meta('description', webpage, 'description', fatal=False))
private_string = 'Only active members can watch private videos.' # print(self._og_search_description(webpage))
is_video_private_regex = re.compile(private_string) # quit()
if re.findall(is_video_private_regex, webpage):
if re.findall(r'Only active members can watch private videos.', webpage):
self.raise_login_required() self.raise_login_required()
title = self._html_search_regex( title = self._html_search_regex(r'<title>(.+?)</title>',
r'<title>(.+?)</title>', webpage, 'title',) webpage,
movie_urls_regex = re.compile("'(https://www.porntrex.com/get_file/.*?)/'") 'title',
movie_urls = re.findall(movie_urls_regex, webpage) fatal=False)
uploader = self._search_regex(r'/members/\d+?/["\']>\s+(.+?)\s+</a>', webpage, 'new_uploader').strip()
thumbnails_regex = re.compile(r'href="(http.*?/screenshots/\d+.jpg/)"') uploader = self._search_regex(r'(?m)/members/\d+?/["\']>\s+(.+?)\s+</a>',
thumbnails_list = re.findall(thumbnails_regex, webpage) webpage,
'new_uploader',
fatal=False).strip()
thumbnails_list = re.findall(r'href="(http.*?/screenshots/\d+.jpg/)["\']', webpage)
thumbnails = [] thumbnails = []
for thumbs in thumbnails_list: for thumbs in thumbnails_list:
thumbnails.append({'url': thumbs}) thumbnails.append({'url': thumbs})
formats = [] formats = []
movie_urls = re.findall(r"['\"](https://www.porntrex.com/get_file/.*?)/['\"]", webpage)
for movie_url in movie_urls: for movie_url in movie_urls:
formats.append({'url': movie_url, formats.append({'url': movie_url,
'ext': movie_url.split('.')[-1], 'height': int(self._search_regex(r'_(\d+)p\.',
'protocol': movie_url.split(':')[0], movie_url,
'height': int(self._search_regex(r'_(\d+)p.', movie_url.split('/')[-1], 'height', default='480')), 'height',
default='480')),
}) })
self._sort_formats(formats) self._sort_formats(formats)
@ -98,43 +106,40 @@ class PornTrexIE(PornTrexBaseIE):
class PornTrexPlayListIE(PornTrexBaseIE): class PornTrexPlayListIE(PornTrexBaseIE):
_NETRC_MACHINE = 'porntrex' _VALID_URL = r'https?://(?:www\.)?porntrex\.com/playlists/(?P<id>[0-9]+)/'
_VALID_URL = \ _TESTS = [{
r'https?://(?:www\.)?porntrex\.com/playlists/(?P<id>[0-9]+)/' 'url': 'https://www.porntrex.com/playlists/13598/tushy32/',
_TEST = {
'url': 'https://www.porntrex.com/playlists/31075/2016-collection/',
'id': '31075',
'title': 'FTVGirls 2016 Collection',
'info_dict': { 'info_dict': {
'id': '345462', 'id': '13598',
'ext': 'mp4', 'title': 'Tushy',
'uploader': 'publicgirls', 'description': 'Huge collection of free hd porn videos. Tons of amateur sex and professional hd movies. Daily updated videos of hot busty teen, latina, amateur & more...',
'title': 'FTVGirls.16.05 - Adria Part 2', },
'description': 'https://www.indexxx.com/models/121033/adria-rae/', 'playlist_mincount': 74,
'age_limit': 18, }, {
} 'url': 'https://www.porntrex.com/playlists/31075/2016-collection/',
} 'info_dict': {
'id': '31075',
'title': 'FTVGirls 2016 Collection',
'description': 'FTVGirls 2016 Complete Collection (122 videos)',
},
'playlist_mincount': 3,
}]
def _real_extract(self, url): def _real_extract(self, url):
playlist_id = self._match_id(url) playlist_id = self._match_id(url)
webpage = self._download_webpage(url, playlist_id) webpage = self._download_webpage(url, playlist_id)
get_all_urls_regex = re.compile('data-playlist-item="(.*?)"') all_urls = re.findall(r'data-playlist-item="(.*?)"', webpage)
all_urls = re.findall(get_all_urls_regex, webpage)
entries = [] entries = []
for this_url in all_urls: for this_url in all_urls:
entries.append({'_type': 'url', entries.append(self.url_result(this_url))
'id': this_url.split('/')[4],
'url': this_url,
})
return { playlist_description = self._html_search_meta('description', webpage, 'description', fatal=False)
'_type': 'playlist',
'id': playlist_id, playlist_title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title', fatal=False)
'title': self._html_search_regex(
r'<title>(.+?)</title>', return self.playlist_result(entries,
webpage, playlist_id=playlist_id,
'title',), playlist_title=playlist_title,
'entries': entries, playlist_description=playlist_description)
}