File size: 2,976 Bytes
8e6ac63
a71fd48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8e6ac63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from pydantic import BaseModel, Field, IPvAnyAddress, ConfigDict


class GenerateUrlRequest(BaseModel):
    mediaflow_proxy_url: str = Field(..., description="The base URL for the mediaflow proxy.")
    endpoint: str | None = Field(None, description="The specific endpoint to be appended to the base URL.")
    destination_url: str | None = Field(None, description="The destination URL to which the request will be proxied.")
    query_params: dict | None = Field(None, description="Query parameters to be included in the request.")
    request_headers: dict | None = Field(None, description="Headers to be included in the request.")
    response_headers: dict | None = Field(None, description="Headers to be included in the response.")
    expiration: int | None = Field(
        None, description="Expiration time for the URL in seconds. If not provided, the URL will not expire."
    )
    api_password: str | None = Field(
        None, description="API password for encryption. If not provided, the URL will only be encoded."
    )
    ip: IPvAnyAddress | None = Field(None, description="The IP address to restrict the URL to.")


class GenericParams(BaseModel):
    model_config = ConfigDict(populate_by_name=True)

    verify_ssl: bool = Field(False, description="Whether to verify the SSL certificate of the destination.")
    use_request_proxy: bool = Field(True, description="Whether to use the MediaFlow proxy configuration.")


class HLSManifestParams(GenericParams):
    destination: str = Field(..., description="The URL of the HLS manifest.", alias="d")
    key_url: str | None = Field(
        None,
        description="The HLS Key URL to replace the original key URL. Defaults to None. (Useful for bypassing some sneaky protection)",
    )


class ProxyStreamParams(GenericParams):
    destination: str = Field(..., description="The URL of the stream.", alias="d")


class MPDManifestParams(GenericParams):
    destination: str = Field(..., description="The URL of the MPD manifest.", alias="d")
    key_id: str | None = Field(None, description="The DRM key ID (optional).")
    key: str | None = Field(None, description="The DRM key (optional).")


class MPDPlaylistParams(GenericParams):
    destination: str = Field(..., description="The URL of the MPD manifest.", alias="d")
    profile_id: str = Field(..., description="The profile ID to generate the playlist for.")
    key_id: str | None = Field(None, description="The DRM key ID (optional).")
    key: str | None = Field(None, description="The DRM key (optional).")


class MPDSegmentParams(GenericParams):
    init_url: str = Field(..., description="The URL of the initialization segment.")
    segment_url: str = Field(..., description="The URL of the media segment.")
    mime_type: str = Field(..., description="The MIME type of the segment.")
    key_id: str | None = Field(None, description="The DRM key ID (optional).")
    key: str | None = Field(None, description="The DRM key (optional).")