Skip to content

Commit

Permalink
progres on sabr context update
Browse files Browse the repository at this point in the history
  • Loading branch information
coletdjnz committed Feb 15, 2025
1 parent c24e1e3 commit a54b1cf
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
23 changes: 19 additions & 4 deletions yt_dlp_plugins/extractor/_ytse/protos/_sabr_context_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@ class ContextUpdate:

@protobug.message
class SabrContextUpdate:
unknown_field_1: typing.Optional[protobug.Int32] = protobug.field(1, default=None) # seen = 2
unknown_field_2: typing.Optional[protobug.Int32] = protobug.field(2, default=None) # seen = 2
context_update: typing.Optional[ContextUpdate] = protobug.field(3, default_factory=ContextUpdate)
unknown_field_4: typing.Optional[protobug.Int32] = protobug.field(4, default=None) # seen = 1

class SabrContextScope(protobug.Enum):
SABR_CONTEXT_SCOPE_UNKNOWN = 0
SABR_CONTEXT_SCOPE_PLAYBACK = 1
SABR_CONTEXT_SCOPE_REQUEST = 2
SABR_CONTEXT_SCOPE_WATCH_ENDPOINT = 3
SABR_CONTEXT_SCOPE_CONTENT_ADS = 4

class SabrContextWritePolicy(protobug.Enum):
# Whether to override existing sabr context updates?
SABR_CONTEXT_WRITE_POLICY_UNSPECIFIED = 0
SABR_CONTEXT_WRITE_POLICY_OVERWRITE = 1
SABR_CONTEXT_WRITE_POLICY_KEEP_EXISTING = 2

type: typing.Optional[protobug.Int32] = protobug.field(1, default=None) # seen = 2
scope: typing.Optional[SabrContextScope] = protobug.field(2, default=None) # seen = 2 (SABR_CONTEXT_SCOPE_REQUEST?)
value: typing.Optional[protobug.Bytes] = protobug.field(3, default=None) # todo: value changes based on type?
send_by_default: typing.Optional[protobug.Bool] = protobug.field(4, default=None) # seen = True
write_policy: typing.Optional[SabrContextWritePolicy] = protobug.field(5, default=None)
10 changes: 7 additions & 3 deletions yt_dlp_plugins/extractor/_ytse/protos/_streamer_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class ClientInfo:
unknown_field_98: typing.Optional[protobug.String] = protobug.field(98, default=None) # seen on android = "google"
gl_device_info: typing.Optional[GLDeviceInfo] = protobug.field(102, default=None)


@protobug.message
class Fqa:
class SentSabrContextUpdate:
type: typing.Optional[protobug.Int32] = protobug.field(1, default=None)
value: typing.Optional[protobug.Bytes] = protobug.field(2, default=None)

Expand All @@ -67,7 +68,10 @@ class StreamerContext:
po_token: typing.Optional[protobug.Bytes] = protobug.field(2, default=None)
playback_cookie: typing.Optional[protobug.Bytes] = protobug.field(3, default=None)
gp: typing.Optional[protobug.Bytes] = protobug.field(4, default=None)
field5: list[Fqa] = protobug.field(5, default_factory=list)
field6: list[protobug.Int32] = protobug.field(6, default_factory=list)
# referred to as "stmctxt". Seems to be the SABR context updates (ad updates) that were applied (sendByDefault was True)
# Also applied for sabr context updates contained within TIMELINE_CONTEXT
sent_sabr_context_updates: list[SentSabrContextUpdate] = protobug.field(5, default_factory=list)
# referred to as "unsntctxt". Is the type in the SABR Context update that was not sent (sendByDefault was False)
unsent_sabr_context_update_types: list[protobug.Int32] = protobug.field(6, default_factory=list)
field7: typing.Optional[protobug.String] = protobug.field(7, default=None)
field8: typing.Optional[Gqa] = protobug.field(8, default=None)
37 changes: 37 additions & 0 deletions yt_dlp_plugins/extractor/_ytse/protos/_timeline_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import typing
import protobug
from . import SabrContextUpdate


@protobug.message
class rkH:
S8: typing.Optional[protobug.String] = protobug.field(1, default=None)
Xn: typing.Optional[protobug.Int32] = protobug.field(2, default=None)
ZJ2: typing.Optional[protobug.Int32] = protobug.field(3, default=None)
sj: typing.Optional[protobug.Int32] = protobug.field(4, default=None)
GU: typing.Optional[protobug.Int32] = protobug.field(5, default=None)
wE: typing.Optional[protobug.Int32] = protobug.field(6, default=None)


@protobug.message
class i8V:
L4: typing.Optional[protobug.Int32] = protobug.field(1, default=None)


@protobug.message
class Clip:
clip_id: typing.Optional[protobug.String] = protobug.field(1, default=None)
T7: typing.Optional[rkH] = protobug.field(2, default=None)
h2: typing.Optional[i8V] = protobug.field(3, default=None)


@protobug.message
class Timeline:
clip: typing.Optional[Clip] = protobug.field(1, default=None)
j2E: typing.Optional[protobug.String] = protobug.field(2, default=None)


@protobug.message
class TimelineContext:
timeline: typing.Optional[Timeline] = protobug.field(1, default=None) # may be a list, todo: confirm
sabr_context_update: typing.Optional[SabrContextUpdate] = protobug.field(2, default=None)

0 comments on commit a54b1cf

Please sign in to comment.