2019-04-14 14:07:25 +02:00
# coding: utf-8
from __future__ import unicode_literals
import re
from . common import InfoExtractor
from . . utils import (
urlencode_postdata ,
ExtractorError ,
)
2019-04-21 22:06:54 +02:00
class PornTrexBaseIE ( InfoExtractor ) :
2019-06-24 03:25:30 +02:00
_NETRC_MACHINE = ' porntrex '
2019-04-14 14:07:25 +02:00
def _login ( self ) :
username , password = self . _get_login_info ( )
if username is None :
return
login_page = self . _download_webpage (
' https://www.porntrex.com/login/ ' , None , ' Downloading login page ' )
login_form = self . _hidden_inputs ( login_page )
login_form . update ( {
2019-06-24 03:25:30 +02:00
' username ' : username ,
' pass ' : password ,
' remember_me ' : 1 ,
2019-04-14 14:07:25 +02:00
} )
login_page = self . _download_webpage (
' https://www.porntrex.com/ajax-login/ ' , None ,
note = ' Logging in ' ,
data = urlencode_postdata ( login_form ) )
if re . search ( r ' generic-error hidden ' , login_page ) :
raise ExtractorError (
' Unable to login, incorrect username and/or password ' ,
expected = True )
def _real_initialize ( self ) :
self . _login ( )
2019-04-21 22:06:54 +02:00
class PornTrexIE ( PornTrexBaseIE ) :
_VALID_URL = r ' https?://(?:www \ .)?porntrex \ .com/video/(?P<id>[0-9]+)/ '
_TEST = {
2019-04-30 03:13:32 +02:00
' url ' : ' https://www.porntrex.com/video/311136/naomi-gets-fingered-before-the-fucking ' ,
2019-04-21 22:06:54 +02:00
' info_dict ' : {
2019-04-30 03:13:32 +02:00
' id ' : ' 311136 ' ,
2019-04-21 22:06:54 +02:00
' ext ' : ' mp4 ' ,
2019-04-30 03:13:32 +02:00
' title ' : ' Naomi gets fingered before the fucking ' ,
' uploader ' : ' cumberland ' ,
' description ' : ' Sexy brunette babe likes to get her tight cunt slammed in hardcore fashion. ' ,
2019-05-15 00:54:59 +02:00
' age_limit ' : 18 ,
2019-04-21 22:06:54 +02:00
}
}
2019-04-14 14:07:25 +02:00
def _real_extract ( self , url ) :
video_id = self . _match_id ( url )
webpage = self . _download_webpage ( url , video_id )
2019-06-24 03:25:30 +02:00
if re . findall ( r ' Only active members can watch private videos. ' , webpage ) :
2019-04-14 14:07:25 +02:00
self . raise_login_required ( )
2019-06-24 03:25:30 +02:00
title = self . _html_search_regex ( r ' <title>(.+?)</title> ' ,
webpage ,
' title ' ,
fatal = False )
uploader = self . _search_regex ( r ' (?m)/members/ \ d+?/[ " \' ]> \ s+(.+?) \ s+</a> ' ,
webpage ,
' new_uploader ' ,
fatal = False ) . strip ( )
thumbnails_list = re . findall ( r ' href= " (http.*?/screenshots/ \ d+.jpg/)[ " \' ] ' , webpage )
2019-04-14 14:07:25 +02:00
thumbnails = [ ]
for thumbs in thumbnails_list :
thumbnails . append ( { ' url ' : thumbs } )
2019-06-24 03:25:30 +02:00
2019-04-14 14:07:25 +02:00
formats = [ ]
2019-06-27 10:27:40 +02:00
movie_urls = re . findall ( r " [ \" ' ](https://www.porntrex.com/get_file/.*?)/[ \" ' ] " , webpage )
2019-05-12 02:00:20 +02:00
for movie_url in movie_urls :
2019-06-27 10:27:40 +02:00
if re . search ( r ' screenshots ' , movie_url ) :
continue
2019-05-12 02:00:20 +02:00
formats . append ( { ' url ' : movie_url ,
2019-06-24 03:25:30 +02:00
' height ' : int ( self . _search_regex ( r ' _( \ d+)p \ . ' ,
movie_url ,
' height ' ,
default = ' 480 ' ) ) ,
2019-04-14 14:07:25 +02:00
} )
self . _sort_formats ( formats )
return {
' id ' : video_id ,
' title ' : title ,
' description ' : self . _og_search_description ( webpage ) ,
' uploader ' : uploader ,
' thumbnails ' : thumbnails ,
' formats ' : formats ,
2019-05-12 02:00:20 +02:00
' age_limit ' : 18 ,
2019-04-14 14:07:25 +02:00
}
2019-04-21 22:06:54 +02:00
class PornTrexPlayListIE ( PornTrexBaseIE ) :
2019-06-24 03:25:30 +02:00
_VALID_URL = r ' https?://(?:www \ .)?porntrex \ .com/playlists/(?P<id>[0-9]+)/ '
_TESTS = [ {
' url ' : ' https://www.porntrex.com/playlists/13598/tushy32/ ' ,
' info_dict ' : {
' id ' : ' 13598 ' ,
' title ' : ' Tushy ' ,
' 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... ' ,
} ,
' playlist_mincount ' : 74 ,
} , {
2019-04-18 22:51:49 +02:00
' url ' : ' https://www.porntrex.com/playlists/31075/2016-collection/ ' ,
2019-04-14 14:07:25 +02:00
' info_dict ' : {
2019-06-24 03:25:30 +02:00
' id ' : ' 31075 ' ,
' title ' : ' FTVGirls 2016 Collection ' ,
' description ' : ' FTVGirls 2016 Complete Collection (122 videos) ' ,
} ,
' playlist_mincount ' : 3 ,
} ]
2019-04-14 14:07:25 +02:00
def _real_extract ( self , url ) :
playlist_id = self . _match_id ( url )
webpage = self . _download_webpage ( url , playlist_id )
2019-06-27 09:42:32 +02:00
all_urls = re . findall ( r ' data-playlist-item=[ " \' ](https?://www \ .porntrex \ .com/[^ \' " ]+) ' , webpage )
2019-04-14 14:07:25 +02:00
entries = [ ]
for this_url in all_urls :
2019-06-24 03:25:30 +02:00
entries . append ( self . url_result ( this_url ) )
2019-04-14 14:07:25 +02:00
2019-06-24 03:25:30 +02:00
playlist_description = self . _html_search_meta ( ' description ' , webpage , ' description ' , fatal = False )
playlist_title = self . _html_search_regex ( r ' <title>(.+?)</title> ' , webpage , ' title ' , fatal = False )
return self . playlist_result ( entries ,
playlist_id = playlist_id ,
playlist_title = playlist_title ,
playlist_description = playlist_description )