brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.53k stars 2.27k forks source link

Download playlist media from background web contents #25062

Closed simonhong closed 1 year ago

simonhong commented 2 years ago

When background web contents is used for downloading media, ads video is downloaded instead of actual contents. cc @sangwoo108

simonhong commented 2 years ago

Tried to check whether shields rule is used or not when youtube url is loaded in background web contents at BraveRequestInfo::MakeCTX() and it seems same rule is applied. Curious why background web contents still gives ads video?..

simonhong commented 2 years ago

@Brandon-T On desktop, sometimes ads video is downloaded instead of actual contents. I'm not sure but I assume adblock enabled state could cause this. AFAIK, desktop uses same script for getting media file list. Curious iOS experienced similar issue?

Brandon-T commented 2 years ago

@Brandon-T

On desktop, sometimes ads video is downloaded instead of actual contents.

I'm not sure but I assume adblock enabled state could cause this.

AFAIK, desktop uses same script for getting media file list.

Curious iOS experienced similar issue?

iOS had the same issue. So we use the adblock shields in the invisible web view. It doesn't happen to use on sites where the user is actively viewing the page. The ads issue only ever happened on the invisible web view so we inject our Adblock shields in there.

simonhong commented 2 years ago

@Brandon-T On desktop, sometimes ads video is downloaded instead of actual contents. I'm not sure but I assume adblock enabled state could cause this. AFAIK, desktop uses same script for getting media file list. Curious iOS experienced similar issue?

iOS had the same issue. So we use the adblock shields in the invisible web view. It doesn't happen to use on sites where the user is actively viewing the page. The ads issue only ever happened on the invisible web view so we inject our Adblock shields in there.

If user disabled shields for youtube and current tab is youtube for example, iOS could download ads also?

Brandon-T commented 2 years ago

@Brandon-T

On desktop, sometimes ads video is downloaded instead of actual contents.

I'm not sure but I assume adblock enabled state could cause this.

AFAIK, desktop uses same script for getting media file list.

Curious iOS experienced similar issue?

iOS had the same issue. So we use the adblock shields in the invisible web view. It doesn't happen to use on sites where the user is actively viewing the page. The ads issue only ever happened on the invisible web view so we inject our Adblock shields in there.

If user disabled shields for youtube and current tab is youtube for example, iOS could download ads also?

In the invisible web view we always load the adblock when downloading. For the videos on the page where there the user disabled Adblock, it will download an ad yeah.

In this case it's up to the user to only add to playlist the actual video.

simonhong commented 2 years ago

@Brandon-T

On desktop, sometimes ads video is downloaded instead of actual contents.

I'm not sure but I assume adblock enabled state could cause this.

AFAIK, desktop uses same script for getting media file list.

Curious iOS experienced similar issue?

iOS had the same issue. So we use the adblock shields in the invisible web view. It doesn't happen to use on sites where the user is actively viewing the page. The ads issue only ever happened on the invisible web view so we inject our Adblock shields in there.

If user disabled shields for youtube and current tab is youtube for example, iOS could download ads also?

In the invisible web view we always load the adblock when downloading. For the videos on the page where there the user disabled Adblock, it will download an ad yeah.

In this case it's up to the user to only add to playlist the actual video.

Got it, thanks for the answer! 👍🏼

sangwoo108 commented 2 years ago

https://github.com/brave/brave-browser/issues/25130

Reportedly, Hiding Media source API on desktop seems to make Youtube streaming unplayable. We may need to download media files on background every time.

So I guess the general flow would be

simonhong commented 1 year ago

Closed as https://github.com/brave/brave-browser/issues/25366 fixed this issue also.