mariosemes / PornHub-downloader-python

Download stuff from PH the easy way.
GNU General Public License v3.0
779 stars 189 forks source link

add code for playlist unlimit 36 videos #64

Open jgqipzmvakfaj opened 3 years ago

jgqipzmvakfaj commented 3 years ago

playlist download will limit 36 videos, i add some code to get all page not enough time test all playlist, but i think it works


from pyquery import PyQuery as pq # bs4 out of the practice
tokenSearch = re.compile('data-token="([a-zA-Z0-9_-]+\.)')
cookies = {
    xxxxxxxxxxxxxxxxxxxxx
}
        url = "https://www.pornhub.com/" + str(row[1]) + "/" + str(row[2] + url_after)
        if str(row[1]) not in ['model', 'users', 'channels']:
            r = requests.get(url,
                             proxies={'http_proxy': 'http://127.0.0.1:xxxx', 'https_proxy': 'http://127.0.0.1:xxxx'},
                             cookies=cookies)
            r.encoding = 'utf8'
            p = pq(r.text)('.usernameWrap.clearfix').text()
            end = int(re.findall('.*- (\d+).*videos', p)[0]) // 40 + 2 # use all videos count the end page

            # print(f'end page {end}')
            token = tokenSearch.findall(r.text)[0] #next page use

            url = "https://www.pornhub.com/{}/viewChunked?id={}&token={}&page={}" # next page format
            for _ in range(1, end):
                with youtube_dl.YoutubeDL(ydl_opts_start) as ydl:
                    ydl.download([url.format(str(row[1]), str(row[2]),token, str(_))])
        else:
            with youtube_dl.YoutubeDL(ydl_opts_start) as ydl:
                ydl.download([url])```
daleao commented 3 days ago

Can you explain where to insert this code?