Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/mildom.py (Python)

Code before:
# coding: utf-8
from __future__ import unicode_literals

import base64
from datetime import datetime
import itertools
import json

from .common import InfoExtractor
from ..utils import (
    std_headers,
    update_url_query,
    random_uuidv4,
    try_get,
)
from ..compat import (
    compat_str,
    compat_numeric_types
)


class MildomBaseIE(InfoExtractor):
    _GUEST_ID = None
    _DISPATCHER_CONFIG = None

    def _call_api(self, url, video_id, query={}, note='Downloading JSON metadata', init=False):
        url = update_url_query(url, self._common_queries(query, init=init))
        content = self._download_json(url, video_id, note=note)
        if content['code'] == 0:
            return content['body']
        else:
            self.raise_no_formats('Video not found or premium content. Mildom error code %i, "%s"'
                                  % (content['code'], content['message']), expected=True)

    def _common_queries(self, query={}, init=False):
        dc = self._fetch_dispatcher_config()
        r = {
            'timestamp': self.iso_timestamp(),
            '__guest_id': '' if init else self.guest_id(),
            '__location': dc['location'],
            '__country': dc['country'],
            '__cluster': dc['cluster'],
            '__platform': 'web',
            '__la': self.lang_code(),
            '__pcv': 'v2.9.44',
            'sfr': 'pc',
            'accessToken': '',
        }
        r.update(query)
        return r


Review comment (suggestion):
Why not just add `__platform` here
```py
def _call_api(self, url, video_id, query=None, note='Downloading JSON metadata', init=False):
    query = query or {}
    if query:
        query['__platform'] = 'web'
```

Code after:
# coding: utf-8
from __future__ import unicode_literals

import base64
from datetime import datetime
import itertools
import json

from .common import InfoExtractor
from ..utils import (
    std_headers,
    update_url_query,
    random_uuidv4,
    try_get,
    float_or_none,
    dict_get
)
from ..compat import (
    compat_str,
)


class MildomBaseIE(InfoExtractor):
    _GUEST_ID = None
    _DISPATCHER_CONFIG = None

    def _call_api(self, url, video_id, query=None, note='Downloading JSON metadata', init=False):
        query = query or {}
        if query:
            query['__platform'] = 'web'
        url = update_url_query(url, self._common_queries(query, init=init))
        content = self._download_json(url, video_id, note=note)
        if content['code'] == 0:
            return content['body']
        else:
            self.raise_no_formats(
                f'Video not found or premium content. {content["code"]} - {content["message"]}',
                expected=True)

    def _common_queries(self, query={}, init=False):
        dc = self._fetch_dispatcher_config()
        r = {
            'timestamp': self.iso_timestamp(),
            '__guest_id': '' if init else self.guest_id(),
            '__location': dc['location'],
            '__country': dc['country'],
            '__cluster': dc['cluster'],
            '__platform': 'web',
            '__la': self.lang_code(),
            '__pcv': 'v2.9.44',
            'sfr': 'pc',