Repository: yt-dlp/yt-dlp

Issue:
Add support for Piapro.jp
### Checklist

- [X] I'm reporting a new site support request
- [X] I've verified that I'm running yt-dlp version **2022.02.04**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that none of provided URLs [violate any copyrights](https://github.com/ytdl-org/youtube-dl#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free) or contain any [DRM](https://en.wikipedia.org/wiki/Digital_rights_management) to the best of my knowledge
- [X] I've searched 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 am willing to share it if required

### Region

_No response_

### Example URLs

https://piapro.jp/content/usxnllt25s8i4ppk
Clicking "Play" in the above opens a separate player window, and "Play" needs to be clicked again there:
https://piapro.jp/html5_player_popup/?id=usxnllt25s8i4ppk&cdate=20220112185026&p=0

### Description

piapro is a Japanese website made for hosting VOCALOID-based media, mainly images, audio, and text.

Here is the upstream bug report from 2015 for reference: https://github.com/ytdl-org/youtube-dl/issues/5856

### Verbose log

```shell
[debug] Command-line config: ['-vU', 'https://piapro.jp/content/usxnllt25s8i4ppk']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, err UTF-8, pref UTF-8
[debug] yt-dlp version 2022.02.04 [c1653e9ef] (zip)
[debug] Python version 3.7.3 (CPython 64bit) - Linux-5.10.83-rm1+-x86_64-with-debian-10.11
[debug] exe versions: ffmpeg 3.2.16-1, ffprobe 3.2.16-1, phantomjs .
[debug] Optional libraries: sqlite
[debug] Proxy map: {}
Latest version: 2022.02.04, Current version: 2022.02.04
yt-dlp is up to date (2022.02.04)
[debug] [generic] Extracting URL: https://piapro.jp/content/usxnllt25s8i4ppk
[generic] usxnllt25s8i4ppk: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] usxnllt25s8i4ppk: Downloading webpage
[generic] usxnllt25s8i4ppk: Extracting information
[debug] Looking for video embeds
ERROR: Unsupported URL: https://piapro.jp/content/usxnllt25s8i4ppk
Traceback (most recent call last):
  File "/root/s/_bin/yt-dlp.real/yt_dlp/YoutubeDL.py", line 1381, in wrapper
    return func(self, *args, **kwargs)
  File "/root/s/_bin/yt-dlp.real/yt_dlp/YoutubeDL.py", line 1451, in __extract_info
    ie_result = ie.extract(url)
  File "/root/s/_bin/yt-dlp.real/yt_dlp/extractor/common.py", line 612, in extract
    ie_result = self._real_extract(url)
  File "/root/s/_bin/yt-dlp.real/yt_dlp/extractor/generic.py", line 3986, in _real_extract
    raise UnsupportedError(url)
yt_dlp.utils.UnsupportedError: Unsupported URL: https://piapro.jp/content/usxnllt25s8i4ppk
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/extractors.py b/yt_dlp/extractor/extractors.py
--- a/yt_dlp/extractor/extractors.py
+++ b/yt_dlp/extractor/extractors.py
@@ -1162,6 +1162,7 @@
 from .philharmoniedeparis import PhilharmonieDeParisIE
 from .phoenix import PhoenixIE
 from .photobucket import PhotobucketIE
+from .piapro import PiaproIE
 from .picarto import (
     PicartoIE,
     PicartoVodIE,
diff --git a/yt_dlp/extractor/piapro.py b/yt_dlp/extractor/piapro.py
new file mode 100644
--- /dev/null
+++ b/yt_dlp/extractor/piapro.py
@@ -0,0 +1,100 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..compat import compat_urlparse
+from ..utils import (
+    ExtractorError,
+    parse_duration,
+    parse_filesize,
+    str_to_int,
+    unified_timestamp,
+    urlencode_postdata,
+)
+
+
+class PiaproIE(InfoExtractor):
+    _NETRC_MACHINE = 'piapro'
+    _VALID_URL = r'https?://piapro\.jp/t/(?P<id>\w+)/?'
+    _TESTS = [{
+        'url': 'https://piapro.jp/t/NXYR',
+        'md5': 'a9d52f27d13bafab7ee34116a7dcfa77',
+        'info_dict': {
+            'id': 'NXYR',
+            'ext': 'mp3',
+            'uploader': 'wowaka',
+            'uploader_id': 'wowaka',
+            'title': '裏表ラバーズ',
+            'thumbnail': r're:^https?://.*\.jpg$',
+        }
+    }]
+
+    def _real_initialize(self):
+        self._login_status = self._login()
+
+    def _login(self):
+        username, password = self._get_login_info()
+        if not username:
+            return False
+        login_ok = True
+        login_form_strs = {
+            '_username': username,
+            '_password': password,
+            '_remember_me': 'on',
+            'login': 'ログイン'
+        }
+        self._request_webpage('https://piapro.jp/login/', None)
+        urlh = self._request_webpage(
+            'https://piapro.jp/login/exe', None,
+            note='Logging in', errnote='Unable to log in',
+            data=urlencode_postdata(login_form_strs))
+        if urlh is False:
+            login_ok = False
+        else:
+            parts = compat_urlparse.urlparse(urlh.geturl())
+            if parts.path != '/':
+                login_ok = False
+        if not login_ok:
+            self.report_warning(
+                'unable to log in: bad username or password')
+        return login_ok
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+        webpage = self._download_webpage(url, video_id)
+
+        category_id = self._search_regex(r'categoryId=(.+)">', webpage, 'category ID')
+        if category_id not in ('1', '2', '21', '22', '23', '24', '25'):
+            raise ExtractorError('The URL does not contain audio.', expected=True)
+
+        str_duration, str_filesize = self._search_regex(
+            r'サイズ：</span>(.+?)/\(([0-9,]+?[KMG]?B)）', webpage, 'duration and size',
+            group=(1, 2), default=(None, None))
+        str_viewcount = self._search_regex(r'閲覧数：</span>([0-9,]+)\s+', webpage, 'view count', fatal=False)
+
+        uploader_id, uploader = self._search_regex(
+            r'<a\s+class="cd_user-name"\s+href="/(.*)">([^<]+)さん<', webpage, 'uploader',
+            group=(1, 2), default=(None, None))
+        content_id = self._search_regex(r'contentId\:\'(.+)\'', webpage, 'content ID')
+        create_date = self._search_regex(r'createDate\:\'(.+)\'', webpage, 'timestamp')
+
+        player_webpage = self._download_webpage(
+            f'https://piapro.jp/html5_player_popup/?id={content_id}&cdate={create_date}',
+            video_id, note='Downloading player webpage')
+
+        return {
+            'id': video_id,
+            'title': self._html_search_regex(r'<h1\s+class="cd_works-title">(.+?)</h1>', webpage, 'title', fatal=False),
+            'description': self._html_search_regex(r'<p\s+class="cd_dtl_cap">(.+?)</p>\s*<div', webpage, 'description', fatal=False),
+            'uploader': uploader,
+            'uploader_id': uploader_id,
+            'timestamp': unified_timestamp(create_date, False),
+            'duration': parse_duration(str_duration),
+            'view_count': str_to_int(str_viewcount),
+            'thumbnail': self._html_search_meta('twitter:image', webpage),
+
+            'filesize_approx': parse_filesize(str_filesize.replace(',', '')),
+            'url': self._search_regex(r'mp3:\s*\'(.*?)\'\}', player_webpage, 'url'),
+            'ext': 'mp3',
+            'vcodec': 'none',
+        }


Test patch: