Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does youtube-dl detect advertisements? #21363

Closed
ischmidt20 opened this issue Jun 11, 2019 · 1 comment
Closed

How does youtube-dl detect advertisements? #21363

ischmidt20 opened this issue Jun 11, 2019 · 1 comment
Labels

Comments

@ischmidt20
Copy link

@ischmidt20 ischmidt20 commented Jun 11, 2019

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

Fox Sports Go recently changed their streaming service. Previously, I used to be able to record live streams and download event replays by passing headers into streamlink. However, recording live with streamlink "works" just fine, but because commercials have some kind of different codec than the actual content, I can't do anything with the resulting .ts file.

However, I can download replays from FOX.com just fine, using a youtube-dl command like this: youtube-dl --hls-prefer-native -f 3750 https://content-auso1.uplynk.com/preplay2/6f324d0648b34576b36ce49160add428/391dec8c1a9a07b70d3062e4bf1a6e3c/4sQNPrWNbJWMzPMP2RXiNy2SFAhlIDUYbUwS2TJwN94h.m3u8?pbs=38dc148aad7c4a7f981a8dd57493a625

The big problems with this are that a) I have to wait until a replay is posted; and b) FOX is very inconsistent as to which events get replays posted and which do not, meaning I'm SOL if I'm trying to save an event that just doesn't have a replay for some reason. If I could record live, this wouldn't be an issue, but again, the commercials are throwing things off.

One of the output lines from youtube-dl is [hlsnative] Total fragments: 1815 (not including 504 ad).

So my question is: how does youtube-dl detect which segments are ads in the .m3u8 file? If I can figure that out, perhaps I can rig streamlink to ignore those segments when recording, saving me a lot of trouble.

Thanks!

@ischmidt20 ischmidt20 added the question label Jun 11, 2019
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jun 11, 2019

def is_ad_fragment_start(s):
return (s.startswith('#ANVATO-SEGMENT-INFO') and 'type=ad' in s
or s.startswith('#UPLYNK-SEGMENT') and s.endswith(',ad'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.