Repository: yt-dlp/yt-dlp

Issue:
Login broken for PornHub premium
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting that yt-dlp is broken on a **supported** site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

USA

### Provide a description that is worded well enough to be understood

Pornhub recently updated their login page to only login using email instead of username. Since this change it is now not possible to login (even when using known good credentials).

I tracked down a login form field name change that is causing the issue, and was able to fix it by updating the field name. 

In the yt_dlp->extractor->pornhub.py _login method, the login form fields that are updated should be updated from `login_form.update({'username' : username,'password': password,})` to `login_form.update({'email' : username,'password': password,})`.

I am not super familiar with github so sorry this isn't a pull request. 

P.S. verbose log attached is an example of pre-update failure. After the update I can confirm it worked. 

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
"C:\Program Files\Python312\python.exe" C:\Dev\pythonProject3\main.py 
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8 (No VT), error utf-8 (No VT), screen utf-8 (No VT)
[debug] yt-dlp version stable@2023.12.30 from yt-dlp/yt-dlp [f10589e34] (pip) API
[debug] params: {'forceprint': {'video': ['filename']}, 'username': '#####HIDDEN INTENTIONALLY#####', 'password': '#####HIDDEN INTENTIONALLY#####', 'verbose': True, 'writethumbnail': True, 'embedthumbnail': True, 'postprocessors': [{'key': 'FFmpegMetadata', 'add_metadata': True}, {'key': 'EmbedThumbnail'}], 'outtmpl': {'default': 'C:\\Group playlist downloaded\\2024-04-18\\%(title)s_%(id)s.%(ext)s'}, 'updatetime': True, 'sleep_interval': 5, 'max_sleep_interval': 15, 'retry_sleep_functions': {'fragment': 60, 'http': 5, 'file_access': 1}, 'retries': 500, 'fragment_retries': 10, 'file_access_retries': 500, 'abort_on_unavailable_fragments': True, 'concurrent_fragment_downloads': 2, 'http_chunk_size': 25000000, 'buffersize': 1000000000000, 'throttledratelimit': 4000000, 'download_archive': 'D:\\archive.txt', 'overwrites': False, 'compat_opts': set(), 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}
[debug] Python 3.12.2 (CPython AMD64 64bit) - Windows-11-10.0.22635-SP0 (OpenSSL 3.0.13 30 Jan 2024)
[debug] exe versions: ffmpeg 6.1.1-full_build-www.gyan.dev (setts), ffprobe 6.1.1-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2023.11.17, mutagen-1.47.0, requests-2.31.0, sqlite3-3.43.1, urllib3-2.1.0, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1798 extractors
[debug] Loading archive file 'D:\\archive.txt'
[PornHub] Extracting URL: https://www.pornhubpremium.com/view_video.php?viewkey=65bff9e374ae2
[PornHub] Downloading pornhubpremium login page
[PornHub] Logging in to pornhubpremium
ERROR: [PornHub] 65bff9e374ae2: Unable to login: Invalid entry. Use a valid email address to log in.
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\common.py", line 718, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 273, in _real_extract
    self._login(host)
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 117, in _login
    raise ExtractorError(

Traceback (most recent call last):
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1587, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1722, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\common.py", line 718, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 273, in _real_extract
    self._login(host)
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 117, in _login
    raise ExtractorError(
yt_dlp.utils.ExtractorError: [PornHub] 65bff9e374ae2: Unable to login: Invalid entry. Use a valid email address to log in.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Dev\pythonProject3\main.py", line 109, in <module>
    ydl.download(urls)
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 3541, in download
    self.__download_wrapper(self.extract_info)(
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 3516, in wrapper
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1576, in extract_info
    return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1605, in wrapper
    self.report_error(str(e), e.format_traceback())
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1054, in report_error
    self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
  File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 993, in trouble
    raise DownloadError(message, exc_info)
yt_dlp.utils.DownloadError: ERROR: [PornHub] 65bff9e374ae2: Unable to login: Invalid entry. Use a valid email address to log in.

Process finished with exit code 1
```



Discussion:
Hey I don’t know anything about GitHub I just searched on google cause I had the same problem and found this and just made this account to comment this, can you help me to get back into my account as well? I also used to login with my username and password and not email.
> ### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
> * [x]  I understand that I will be **blocked** if I _intentionally_ remove or skip any mandatory* field
> 
> ### Checklist
> * [x]  I'm reporting that yt-dlp is broken on a **supported** site
> * [x]  I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
> * [x]  I've checked that all provided URLs are playable in a browser with the same IP and same login details
> * [x]  I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
> * [x]  I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
> * [x]  I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
> * [x]  I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required
> 
> ### Region
> USA
> 
> ### Provide a description that is worded well enough to be understood
> Pornhub recently updated their login page to only login using email instead of username. Since this change it is now not possible to login (even when using known good credentials).
> 
> I tracked down a login form field name change that is causing the issue, and was able to fix it by updating the field name.
> 
> In the yt_dlp->extractor->pornhub.py _login method, the login form fields that are updated should be updated from `login_form.update({'username' : username,'password': password,})` to `login_form.update({'email' : username,'password': password,})`.
> 
> I am not super familiar with github so sorry this isn't a pull request.
> 
> P.S. verbose log attached is an example of pre-update failure. After the update I can confirm it worked.
> 
> ### Provide verbose output that clearly demonstrates the problem
> * [x]  Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
> * [x]  If using API, add `'verbose': True` to `YoutubeDL` params instead
> * [x]  Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below
> 
> ### Complete Verbose Output
> ```shell
> "C:\Program Files\Python312\python.exe" C:\Dev\pythonProject3\main.py 
> [debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8 (No VT), error utf-8 (No VT), screen utf-8 (No VT)
> [debug] yt-dlp version stable@2023.12.30 from yt-dlp/yt-dlp [f10589e34] (pip) API
> [debug] params: {'forceprint': {'video': ['filename']}, 'username': '#####HIDDEN INTENTIONALLY#####', 'password': '#####HIDDEN INTENTIONALLY#####', 'verbose': True, 'writethumbnail': True, 'embedthumbnail': True, 'postprocessors': [{'key': 'FFmpegMetadata', 'add_metadata': True}, {'key': 'EmbedThumbnail'}], 'outtmpl': {'default': 'C:\\Group playlist downloaded\\2024-04-18\\%(title)s_%(id)s.%(ext)s'}, 'updatetime': True, 'sleep_interval': 5, 'max_sleep_interval': 15, 'retry_sleep_functions': {'fragment': 60, 'http': 5, 'file_access': 1}, 'retries': 500, 'fragment_retries': 10, 'file_access_retries': 500, 'abort_on_unavailable_fragments': True, 'concurrent_fragment_downloads': 2, 'http_chunk_size': 25000000, 'buffersize': 1000000000000, 'throttledratelimit': 4000000, 'download_archive': 'D:\\archive.txt', 'overwrites': False, 'compat_opts': set(), 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}
> [debug] Python 3.12.2 (CPython AMD64 64bit) - Windows-11-10.0.22635-SP0 (OpenSSL 3.0.13 30 Jan 2024)
> [debug] exe versions: ffmpeg 6.1.1-full_build-www.gyan.dev (setts), ffprobe 6.1.1-full_build-www.gyan.dev
> [debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2023.11.17, mutagen-1.47.0, requests-2.31.0, sqlite3-3.43.1, urllib3-2.1.0, websockets-12.0
> [debug] Proxy map: {}
> [debug] Request Handlers: urllib, requests, websockets
> [debug] Loaded 1798 extractors
> [debug] Loading archive file 'D:\\archive.txt'
> [PornHub] Extracting URL: https://www.pornhubpremium.com/view_video.php?viewkey=65bff9e374ae2
> [PornHub] Downloading pornhubpremium login page
> [PornHub] Logging in to pornhubpremium
> ERROR: [PornHub] 65bff9e374ae2: Unable to login: Invalid entry. Use a valid email address to log in.
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\common.py", line 718, in extract
>     ie_result = self._real_extract(url)
>                 ^^^^^^^^^^^^^^^^^^^^^^^
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 273, in _real_extract
>     self._login(host)
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 117, in _login
>     raise ExtractorError(
> 
> Traceback (most recent call last):
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1587, in wrapper
>     return func(self, *args, **kwargs)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1722, in __extract_info
>     ie_result = ie.extract(url)
>                 ^^^^^^^^^^^^^^^
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\common.py", line 718, in extract
>     ie_result = self._real_extract(url)
>                 ^^^^^^^^^^^^^^^^^^^^^^^
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 273, in _real_extract
>     self._login(host)
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\extractor\pornhub.py", line 117, in _login
>     raise ExtractorError(
> yt_dlp.utils.ExtractorError: [PornHub] 65bff9e374ae2: Unable to login: Invalid entry. Use a valid email address to log in.
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "C:\Dev\pythonProject3\main.py", line 109, in <module>
>     ydl.download(urls)
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 3541, in download
>     self.__download_wrapper(self.extract_info)(
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 3516, in wrapper
>     res = func(*args, **kwargs)
>           ^^^^^^^^^^^^^^^^^^^^^
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1576, in extract_info
>     return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1605, in wrapper
>     self.report_error(str(e), e.format_traceback())
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 1054, in report_error
>     self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
>   File "C:\Users\Andrew\AppData\Roaming\Python\Python312\site-packages\yt_dlp\YoutubeDL.py", line 993, in trouble
>     raise DownloadError(message, exc_info)
> yt_dlp.utils.DownloadError: ERROR: [PornHub] 65bff9e374ae2: Unable to login: Invalid entry. Use a valid email address to log in.
> 
> Process finished with exit code 1
> ```

I’m not sure if u get notified by my comment or how it works hope u see this
@Parthpatel2006 For a temporary work around - if you go to the location you installed yt_dlp to you will need to edit a python file. 

File the file yt_dlp->extractor->pornhub.py 

Inside that file there is a function called _login. Within that function you will need to find `login_form.update({'username' : username,'password': password,})` and update it to be `login_form.update({'email' : username,'password': password,})`.

Then save the file and it should work. Just make sure update your credentials so that they use the email instead of username. 
@pukkandan @AJKnabenbauer @bashonly @haraldmartin do any of y’all know if y’all can help me with this concerning my comment above of me not knowing anything about GitHub and coding but having the same login issue?
someone just needs to open a PR of the patch in the OP and I will merge it
What does that mean?
@AJKnabenbauer i don't know what that means. Could I give you my username and password and u do it? Not sure what a yt_dlp is is or anything (also I had just seen that u sent that message my bad)
> Not sure what a yt_dlp is is or anything

@Parthpatel2006 Where are you seeing this issue then? This bug tracker is purely for yt-dlp, a free and open source command line video downloader. If you are not using yt-dlp, you are in the wrong place.

A PR means Pull Request. Someone needs to properly send in the above code changes, and once merged this bug will be fixed.
@seproDev oh i thought this was a way to log in using only your username and password. Since i don’t know my email and had been using my username to sign into pornhub for past couple years but now it requires you to sign in with email. (Is there any way you can make it to where you can sign in with your username so I can access my account?)
@Parthpatel2006 no, the site has changed how login works. This issue tracker is for yt-dlp, we are not affiliated with the site in any way and have no control over how their login works.

This issue is about how the site's change *broke* yt-dlp, and how yt-dlp needs to adjust to the new email/password login method.

Resolving patch:
diff --git a/yt_dlp/extractor/pornhub.py b/yt_dlp/extractor/pornhub.py
--- a/yt_dlp/extractor/pornhub.py
+++ b/yt_dlp/extractor/pornhub.py
@@ -97,7 +97,7 @@ def is_logged(webpage):
         login_form = self._hidden_inputs(login_page)
 
         login_form.update({
-            'username': username,
+            'email': username,
             'password': password,
         })
 


Test patch: