Repository: yt-dlp/yt-dlp

Issue:
[20.detik] Site request for 20.detik
### Checklist

- [X] I'm reporting a new site support request
- [X] I've verified that I'm running yt-dlp version **2022.06.29** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [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 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)
- [ ] 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

Indonesia

### Example URLs

Single video: https://20.detik.com/viral/20220603-220603135/merasakan-bus-imut-tanpa-pengemudi-muter-muter-di-kawasan-bsd-city

### Provide a description that is worded well enough to be understood

Detik,com is an Indonesian online news provider and most ( if not all) of news video is provided in 20.detik.com. See https://en.wikipedia.org/wiki/Detik.com for information.

This sites have two `json/ld` and the first of `json/ld` is more useful than the second,
Here's the first `json/ld` that i get:

```html
<script type="application/ld+json">{
    "@context": "http://schema.org",
    "@type": "VideoObject",
    "name": "Merasakan Bus Imut Tanpa Pengemudi, Muter-muter di Kawasan BSD City",
    "description": "Pemerintah belum lama ini meresmikan Autonomous Electric Vehicles (AV) atau kendaraan listrik tanpa awak di kawasan Q Biq, BSD City, Tangerang Selatan. Kendaraan ini disebut-sebut kendaraan yang ramah lingkungan, sebab menggunakan bahan bakar listrik yang mampu bertahan selama 9 jam.\r\nSelain tanpa awak, hebatnya otonomus shuttle ini mempunyai sensitivitas yang sangat tinggi terhadap bahaya di sekitarnya. Penasaran bagaimana uniknya mobil ini? Simak selengkapnya di sini.",
    "thumbnailUrl": "https://cdnv.detik.com/videoservice/AdminTV/2022/06/03/VIRAL_BUS_NO_SUPIR-20220604004707-custom.jpg?w=650&q=80",
    "uploadDate": "2022-06-04T00:58:25.000Z",
    "duration": "PT9M53S",
    "keywords": "viral,autonomous vehicle,electric,shuttle bus",
    "url": "https://20.detik.com/viral/20220603-220603135/merasakan-bus-imut-tanpa-pengemudi-muter-muter-di-kawasan-bsd-city",
    "embedUrl": "https://20.detik.com/embed/220603135"
}</script>
```
We can use this `json/ld` for metadata as the `url` and `embedUrl`.
We can get the video url in one of `script` tag. Here's the tag:
```html
<script src="[https://cdn.detik.net.id/detikVideo/detikVideo.core.js?v=2022070612](view-source:https://cdn.detik.net.id/detikVideo/detikVideo.core.js?v=2022070612)">
                    {
                        target      : 'detikVideoId',
                        title       : video_title,
                        autoplay    : false,
                        mute        : false,
                        live        : false,
                        imageUrl    : "https://cdnv.detik.com/videoservice/AdminTV/2022/06/03/VIRAL_BUS_NO_SUPIR-20220604004707-custom.jpg?w=400&q=80",
                        videoUrl    : "https://vod.detik.com/mc/_definst_/smil:http/mc/video/detiktv/videoservice/AdminTV/2022/06/03/747fa4eaa9154203999310c1fb564cf0.smil/playlist.m3u8",
                        adRules     : null,
                        channel     : "vod",
                        libs: {
                            reviveAVOC: "https://cdn.detik.net.id/commerce/revive/reviveavoc.js"
                        },
                        ...                                                     
                        }
                    }
                </script>
```
As we can see, we can get the m3u8 url from `videoUrl`.

### 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] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
C:\Users\USER\Downloads>yt-dlp -vU "https://20.detik.com/detikflash/20220705-220705098/zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali" --ignore-config
[debug] Command-line config: ['-vU', 'https://20.detik.com/detikflash/20220705-220705098/zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali', '--ignore-config']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.06.29 [9d339c4] (win32_exe)
[debug] Python 3.8.10 (CPython 64bit) - Windows-10-10.0.19044-SP0
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg 5.0.1-full_build-www.gyan.dev (setts), ffprobe 5.0.1-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.06.15, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {}
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
[debug] Downloading _update_spec from https://github.com/yt-dlp/yt-dlp/releases/download/2022.06.29/_update_spec
Latest version: 2022.06.29, Current version: 2022.06.29
yt-dlp is up to date (2022.06.29)
[debug] [generic] Extracting URL: https://20.detik.com/detikflash/20220705-220705098/zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali
[generic] zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali: Downloading webpage
[generic] zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali: Extracting information
[debug] Looking for video embeds
ERROR: Unsupported URL: https://20.detik.com/detikflash/20220705-220705098/zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali
Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1420, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1490, in __extract_info
  File "yt_dlp\extractor\common.py", line 640, in extract
  File "yt_dlp\extractor\generic.py", line 4130, in _real_extract
yt_dlp.utils.UnsupportedError: Unsupported URL: https://20.detik.com/detikflash/20220705-220705098/zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali
```



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
@@ -376,6 +376,7 @@
     DeezerAlbumIE,
 )
 from .democracynow import DemocracynowIE
+from .detik import Detik20IE
 from .dfb import DFBIE
 from .dhm import DHMIE
 from .digg import DiggIE
diff --git a/yt_dlp/extractor/detik.py b/yt_dlp/extractor/detik.py
new file mode 100644
--- /dev/null
+++ b/yt_dlp/extractor/detik.py
@@ -0,0 +1,122 @@
+from .common import InfoExtractor
+from ..utils import merge_dicts, str_or_none
+
+
+class Detik20IE(InfoExtractor):
+    IE_NAME = '20.detik.com'
+    _VALID_URL = r'https?://20\.detik\.com/((?!program)[\w-]+)/[\d-]+/(?P<id>[\w-]+)'
+    _TESTS = [{
+        # detikflash
+        'url': 'https://20.detik.com/detikflash/20220705-220705098/zulhas-klaim-sukses-turunkan-harga-migor-jawa-bali',
+        'info_dict': {
+            'id': '220705098',
+            'ext': 'mp4',
+            'duration': 157,
+            'thumbnail': 'https://cdnv.detik.com/videoservice/AdminTV/2022/07/05/bfe0384db04f4bbb9dd5efc869c5d4b1-20220705164334-0s.jpg?w=650&q=80',
+            'description': 'md5:ac18dcee5b107abbec1ed46e0bf400e3',
+            'title': 'Zulhas Klaim Sukses Turunkan Harga Migor Jawa-Bali',
+            'tags': ['zulkifli hasan', 'menteri perdagangan', 'minyak goreng'],
+            'timestamp': 1657039548,
+            'upload_date': '20220705'
+        }
+    }, {
+        # e-flash
+        'url': 'https://20.detik.com/e-flash/20220705-220705109/ahli-level-ppkm-jadi-payung-strategi-protokol-kesehatan',
+        'info_dict': {
+            'id': '220705109',
+            'ext': 'mp4',
+            'tags': ['ppkm jabodetabek', 'dicky budiman', 'ppkm'],
+            'upload_date': '20220705',
+            'duration': 110,
+            'title': 'Ahli: Level PPKM Jadi Payung Strategi Protokol Kesehatan',
+            'thumbnail': 'https://cdnv.detik.com/videoservice/AdminTV/2022/07/05/Ahli-_Level_PPKM_Jadi_Payung_Strat_jOgUMCN-20220705182313-custom.jpg?w=650&q=80',
+            'description': 'md5:4eb825a9842e6bdfefd66f47b364314a',
+            'timestamp': 1657045255,
+        }
+    }, {
+        # otobuzz
+        'url': 'https://20.detik.com/otobuzz/20220704-220704093/mulai-rp-10-jutaan-ini-skema-kredit-mitsubishi-pajero-sport',
+        'info_dict': {
+            'id': '220704093',
+            'ext': 'mp4',
+            'tags': ['cicilan mobil', 'mitsubishi pajero sport', 'mitsubishi', 'pajero sport'],
+            'timestamp': 1656951521,
+            'duration': 83,
+            'upload_date': '20220704',
+            'thumbnail': 'https://cdnv.detik.com/videoservice/AdminTV/2022/07/04/5d6187e402ec4a91877755a5886ff5b6-20220704161859-0s.jpg?w=650&q=80',
+            'description': 'md5:9b2257341b6f375cdcf90106146d5ffb',
+            'title': 'Mulai Rp 10 Jutaan! Ini Skema Kredit Mitsubishi Pajero Sport',
+        }
+    }, {
+        # sport-buzz
+        'url': 'https://20.detik.com/sport-buzz/20220704-220704054/crash-crash-horor-di-paruh-pertama-motogp-2022',
+        'info_dict': {
+            'id': '220704054',
+            'ext': 'mp4',
+            'thumbnail': 'https://cdnv.detik.com/videoservice/AdminTV/2022/07/04/6b172c6fb564411996ea145128315630-20220704090746-0s.jpg?w=650&q=80',
+            'title': 'Crash-crash Horor di Paruh Pertama MotoGP 2022',
+            'description': 'md5:fbcc6687572ad7d16eb521b76daa50e4',
+            'timestamp': 1656925591,
+            'duration': 107,
+            'tags': ['marc marquez', 'fabio quartararo', 'francesco bagnaia', 'motogp crash', 'motogp 2022'],
+            'upload_date': '20220704',
+        }
+    }, {
+        # adu-perspektif
+        'url': 'https://20.detik.com/adu-perspektif/20220518-220518144/24-tahun-reformasi-dan-alarm-demokrasi-dari-filipina',
+        'info_dict': {
+            'id': '220518144',
+            'ext': 'mp4',
+            'title': '24 Tahun Reformasi dan Alarm Demokrasi dari Filipina',
+            'upload_date': '20220518',
+            'timestamp': 1652913823,
+            'duration': 185.0,
+            'tags': ['politik', 'adu perspektif', 'indonesia', 'filipina', 'demokrasi'],
+            'description': 'md5:8eaaf440b839c3d02dca8c9bbbb099a9',
+            'thumbnail': 'https://cdnv.detik.com/videoservice/AdminTV/2022/05/18/adpers_18_mei_compressed-20220518230458-custom.jpg?w=650&q=80',
+        }
+    }, {
+        # sosok
+        'url': 'https://20.detik.com/sosok/20220702-220703032/resa-boenard-si-princess-bantar-gebang',
+        'info_dict': {
+            'id': '220703032',
+            'ext': 'mp4',
+            'timestamp': 1656824438,
+            'thumbnail': 'https://cdnv.detik.com/videoservice/AdminTV/2022/07/02/SOSOK_BGBJ-20220702191138-custom.jpg?w=650&q=80',
+            'title': 'Resa Boenard Si \'Princess Bantar Gebang\'',
+            'description': 'md5:84ea66306a0285330de6a13fc6218b78',
+            'tags': ['sosok', 'sosok20d', 'bantar gebang', 'bgbj', 'resa boenard', 'bantar gebang bgbj', 'bgbj bantar gebang', 'sosok bantar gebang', 'sosok bgbj', 'bgbj resa boenard'],
+            'upload_date': '20220703',
+            'duration': 650,
+        }
+    }, {
+        # viral
+        'url': 'https://20.detik.com/viral/20220603-220603135/merasakan-bus-imut-tanpa-pengemudi-muter-muter-di-kawasan-bsd-city',
+        'info_dict': {
+            'id': '220603135',
+            'ext': 'mp4',
+            'description': 'md5:4771fe101aa303edb829c59c26f9e7c6',
+            'timestamp': 1654304305,
+            'title': 'Merasakan Bus Imut Tanpa Pengemudi, Muter-muter di Kawasan BSD City',
+            'tags': ['viral', 'autonomous vehicle', 'electric', 'shuttle bus'],
+            'thumbnail': 'https://cdnv.detik.com/videoservice/AdminTV/2022/06/03/VIRAL_BUS_NO_SUPIR-20220604004707-custom.jpg?w=650&q=80',
+            'duration': 593,
+            'upload_date': '20220604',
+        }
+    }]
+
+    def _real_extract(self, url):
+        display_id = self._match_id(url)
+        webpage = self._download_webpage(url, display_id)
+        json_ld_data = self._search_json_ld(webpage, display_id)
+
+        video_url = self._html_search_regex(
+            r'videoUrl\s*:\s*"(?P<video_url>[^"]+)', webpage, 'videoUrl')
+        formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, display_id, ext='mp4')
+
+        return merge_dicts(json_ld_data, {
+            'id': self._html_search_meta('video_id', webpage),
+            'formats': formats,
+            'subtitles': subtitles,
+            'tags': str_or_none(self._html_search_meta(['keywords', 'keyword', 'dtk:keywords'], webpage), '').split(','),
+        })


Test patch: