8000 [iOS] - Fix playlist auto-download when adding an item by Brandon-T · Pull Request #28594 · brave/brave-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[iOS] - Fix playlist auto-download when adding an item #28594

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

Merged
merged 3 commits into from
Apr 17, 2025

Conversation

Brandon-T
Copy link
Contributor
@Brandon-T Brandon-T commented Apr 10, 2025

Summary

  • Cleanup Code
  • Fix auto-download so it spawns an invisible WebView to download blobs items automatically in the background, when added

Resolves brave/brave-browser#44652

Test Plan

  • Add a 4K item from Youtube to playlist
  • Wait a while (maybe wait about 10-20s? Depends on internet speed and size of item)
  • Open Playlist
  • The item should be downloaded already

Screenshots

  • We can see the item has a src with blob:https://m.youtube.com/....
  • We can see the newItem has a src with https://rr5---sn and it downloads newItem: PlaylistManager.shared.autoDownload(item: newItem)
image

@Brandon-T Brandon-T added CI/skip-android Do not run CI builds for Android CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-windows-x64 Do not run CI builds for Windows x64 unused-CI/skip-linux-x64 Do not run CI builds for Linux x64 CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-teamcity Do not run builds in TeamCity labels Apr 10, 2025
@Brandon-T Brandon-T self-assigned this Apr 10, 2025
@Brandon-T Brandon-T requested a review from a team as a code owner April 10, 2025 14:31
@Brandon-T Brandon-T changed the title Fix playlist auto-download when adding an item [iOS] - Fix playlist auto-download when adding an item Apr 10, 2025
@Brandon-T Brandon-T force-pushed the bugfix/PlaylistAutoDownload branch from 9b191a4 to 0992766 Compare April 11, 2025 17:54
@Brandon-T Brandon-T requested a review from kylehickinson April 11, 2025 17:54
Comment on lines 386 to 390 8000
self.updatePlaylistURLBar(
tab: self.tabManager.selectedTab,
state: .existingItem,
item: newItem
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author
@Brandon-T Brandon-T Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a lot of testing, it's not needed, so I removed it. My main concern was that when I open the video from the page, it'd open the incorrect video because the URL is different and because of threading differences (page might update the URL before the func runs), but I was wrong. It actually opens correctly and it deletes correctly.

Comment on lines 383 to 384
let newItem = (try? await mediaStreamer.loadMediaStreamingAsset(item)) ?? item
PlaylistManager.shared.autoDownload(item: newItem)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just not bother auto-downloading if loadMediaStreamingAsset fails since its not going to work anyways

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

isInvisible: item.isInvisible
)
item.pageSrc = tab.visibleURL?.absoluteString ?? item.pageSrc
item.pageTitle = tab.title ?? item.pageTitle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastPlayedOffset was reset to 0 before change

Copy link
Contributor Author
@Brandon-T Brandon-T Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had removed it because I didn't see it making any difference in practice, and I didn't want to modify the last played offset for a video which might have updated.

So I made a test, I created a video, then added it to playlist. Then I modified that video to something else on Youtube, and when the video in playlist updated, the offset was wrong. So there is good reason to set it to 0.0 here.

I reverted the change.

else {
return
}
public func canAutoDownload(item: PlaylistInfo) -> Bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displaye 8000 d to describe this comment to others. Learn more.

item is not used here, did you mean to also check the item's url scheme for blob here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to remove this change, but decided to keep it lol. So I added the blob check which is a good idea.

@Brandon-T Brandon-T force-pushed the bugfix/PlaylistAutoDownload branch from 0992766 to e66671d Compare April 16, 2025 14:39
@Brandon-T Brandon-T requested a review from kylehickinson April 16, 2025 14:43
Copy link
Contributor

Chromium major version is behind target branch (135.0.7049.100 vs 136.0.7103.25). Please rebase.

@github-actions github-actions bot added the chromium-version-mismatch The Chromium version on the PR branch does not match the version on the target branch label Apr 16, 2025
@Brandon-T Brandon-T force-pushed the bugfix/PlaylistAutoDownload branch from e66671d to f2f68c7 Compare April 17, 2025 14:09
@github-actions github-actions bot removed the chromium-version-mismatch The Chromium version on the PR branch does not match the version on the target branch label Apr 17, 2025
@Brandon-T Brandon-T merged commit 83faed2 into master Apr 17, 2025
18 checks passed
@Brandon-T Brandon-T deleted the bugfix/PlaylistAutoDownload branch April 17, 2025 16:10
@github-actions github-actions bot added this to the 1.79.x - Nightly milestone Apr 17, 2025
@brave-builds
Copy link
Collaborator

Released in v1.79.75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-android Do not run CI builds for Android CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-teamcity Do not run builds in TeamCity CI/skip-windows-x64 Do not run CI builds for Windows x64 unused-CI/skip-linux-x64 Do not run CI builds for Linux x64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fallback to download playlist item via background process when the initial attempt fails.
3 participants
0