Repository: yt-dlp/yt-dlp

Issue:
[viki] bad request, unable to download
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.01.21**. ([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 all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#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 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

Poland

### Description

Downloading from Viki has stopped working. I've tried many different dramas but to no avail.

### Verbose log

```shell
[debug] Command-line config: ['-vU', 'https://www.viki.com/tv/32240c-the-legend-of-the-blue-sea', '--playlist-items', '1', '--username', 'PRIVATE', '--password', 'PRIVATE']
[debug] Encodings: locale cp1250, fs utf-8, out utf-8, err utf-8, pref cp1250
[debug] yt-dlp version 2022.01.21 [f20d607] (win_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19043-SP0
[debug] exe versions: ffmpeg 4.4.1-essentials_build-www.gyan.dev (setts), ffprobe 4.4.1-essentials_build-www.gyan.dev
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.01.21, Current version: 2022.01.21
yt-dlp is up to date (2022.01.21)
[viki:channel] Logging in
[debug] [viki:channel] Extracting URL: https://www.viki.com/tv/32240c-the-legend-of-the-blue-sea
[viki:channel] 32240c: Downloading channel JSON
[download] Downloading playlist: The Legend of the Blue Sea
[viki:channel] 32240c: Downloading Episodes JSON page 1
[viki:channel] playlist The Legend of the Blue Sea: Downloading 1 videos
[download] Downloading video 1 of 1
[viki] Logging in
[debug] [viki] Extracting URL: https://www.viki.com/videos/1115637v
[viki] 1115637v: Downloading video JSON
[viki] 1115637v: Downloading video streams JSON
ERROR: [viki] 1115637v: viki said: Bad request
  File "yt_dlp\extractor\common.py", line 612, in extract
  File "yt_dlp\extractor\viki.py", line 255, in _real_extract
  File "yt_dlp\extractor\viki.py", line 78, in _call_api
  File "yt_dlp\extractor\viki.py", line 86, in _raise_error

[download] Finished downloading playlist: The Legend of the Blue Sea
```



Discussion:
Could you check if the video is Kokowa https://github.com/yt-dlp/yt-dlp/issues/1379#issuecomment-950114372
It's not, just standard VikiPass
Free TV shows are also not working, so you don't need an account to test.

```
yt-dlp -F https://www.viki.com/videos/1101211v-reply-1988-episode-1
[viki] 1101211v: Downloading video JSON
[viki] 1101211v: Downloading video streams JSON
ERROR: [viki] 1101211v: viki said: Bad request
```
I'm facing same issues 
Here too:  
ERROR: [viki] 1175823v: viki said: Bad request
```
{'vcode': 6400, 'error': 'Bad request', 'details': 'invalid drm type'
```
Unfortunately, it's already patched. They already removed the drm type/tag for non-drm content.
I don't think so if there will be another method for non-drm.
same problem here, also bad request
@bbibbimiau Don't promote piracy sites here!

Resolving patch:
diff --git a/yt_dlp/extractor/viki.py b/yt_dlp/extractor/viki.py
--- a/yt_dlp/extractor/viki.py
+++ b/yt_dlp/extractor/viki.py
@@ -19,7 +19,7 @@ class VikiBaseIE(InfoExtractor):
     _VALID_URL_BASE = r'https?://(?:www\.)?viki\.(?:com|net|mx|jp|fr)/'
     _API_URL_TEMPLATE = 'https://api.viki.io%s'
 
-    _DEVICE_ID = '86085977d'  # used for android api
+    _DEVICE_ID = '112395910d'
     _APP = '100005a'
     _APP_VERSION = '6.11.3'
     _APP_SECRET = 'd96704b180208dbb2efa30fe44c48bd8690441af9f567ba8fd710a72badc85198f7472'
@@ -253,7 +253,7 @@ def _real_extract(self, url):
         } for thumbnail_id, thumbnail in (video.get('images') or {}).items() if thumbnail.get('url')]
 
         resp = self._call_api(
-            'playback_streams/%s.json?drms=dt1,dt2&device_id=%s' % (video_id, self._DEVICE_ID),
+            'playback_streams/%s.json?drms=dt3&device_id=%s' % (video_id, self._DEVICE_ID),
             video_id, 'Downloading video streams JSON')['main'][0]
 
         stream_id = try_get(resp, lambda x: x['properties']['track']['stream_id'])
@@ -264,10 +264,13 @@ def _real_extract(self, url):
         } for ext in ('srt', 'vtt')]) for lang in (video.get('subtitle_completions') or {}).keys())
 
         mpd_url = resp['url']
-        # 1080p is hidden in another mpd which can be found in the current manifest content
+        # 720p is hidden in another MPD which can be found in the current manifest content
         mpd_content = self._download_webpage(mpd_url, video_id, note='Downloading initial MPD manifest')
         mpd_url = self._search_regex(
             r'(?mi)<BaseURL>(http.+.mpd)', mpd_content, 'new manifest', default=mpd_url)
+        if 'mpdhd_high' not in mpd_url:
+            # Modify the URL to get 1080p
+            mpd_url = mpd_url.replace('mpdhd', 'mpdhd_high')
         formats = self._extract_mpd_formats(mpd_url, video_id)
         self._sort_formats(formats)
 


Test patch: