mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-14 06:10:35 +05:30
Refactor extract_plid
This commit is contained in:
parent
80fc60b5e2
commit
c97cdf551e
@ -39,33 +39,13 @@ def fetch_trending(trending_type, region, locale)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract_plid(url)
|
def extract_plid(url)
|
||||||
wrapper = HTTP::Params.parse(URI.parse(url).query.not_nil!)["bp"]
|
plid = URI.parse(url)
|
||||||
|
.try { |i| HTTP::Params.parse(i.query.not_nil!)["bp"] }
|
||||||
wrapper = URI.decode_www_form(wrapper)
|
.try { |i| URI.decode_www_form(i) }
|
||||||
wrapper = Base64.decode(wrapper)
|
.try { |i| Base64.decode(i) }
|
||||||
|
.try { |i| IO::Memory.new(i) }
|
||||||
# 0xe2 0x02 0x2e
|
.try { |i| Protodec::Any.parse(i) }
|
||||||
wrapper += 3
|
.try { |i| i["44:0:embedded"]["2:1:string"].as_s }
|
||||||
|
|
||||||
# 0x0a
|
|
||||||
wrapper += 1
|
|
||||||
|
|
||||||
# Looks like "/m/[a-z0-9]{5}", not sure what it does here
|
|
||||||
|
|
||||||
item_size = wrapper[0]
|
|
||||||
wrapper += 1
|
|
||||||
item = wrapper[0, item_size]
|
|
||||||
wrapper += item.size
|
|
||||||
|
|
||||||
# 0x12
|
|
||||||
wrapper += 1
|
|
||||||
|
|
||||||
plid_size = wrapper[0]
|
|
||||||
wrapper += 1
|
|
||||||
plid = wrapper[0, plid_size]
|
|
||||||
wrapper += plid.size
|
|
||||||
|
|
||||||
plid = String.new(plid)
|
|
||||||
|
|
||||||
return plid
|
return plid
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user