Open more YouTube link types and playlists from links

Route YouTube search results links to search and nocookie embeds to the
video, match YouTube hosts exactly, and report YouTube pages without a
video as unsupported instead of sending them to yt-dlp. A watch link
inside a playlist shows both the video and the playlist when loaded, and
plays the video with the playlist queued around it. URL scheme play,
queue and bookmark actions accept playlist links.
This commit is contained in:
Arkadiusz Fal
2026-10-08 22:50:36 +02:00
parent 8a7218ed1b
commit 45e19e6536
10 changed files with 388 additions and 60 deletions

View File

@@ -24,6 +24,30 @@ extension DataManager {
return playlist
}
/// A title no local playlist has yet: the base, else "Base (2)", "Base (3)"…
func uniquePlaylistTitle(_ baseTitle: String) -> String {
let existingTitles = Set(playlists().map(\.title))
guard existingTitles.contains(baseTitle) else { return baseTitle }
var counter = 2
while existingTitles.contains("\(baseTitle) (\(counter))") {
counter += 1
}
return "\(baseTitle) (\(counter))"
}
/// Saves a remote playlist's videos as a new local playlist.
@discardableResult
func importPlaylist(_ playlist: Playlist) -> LocalPlaylist {
let localPlaylist = createPlaylist(
title: uniquePlaylistTitle(playlist.title),
description: playlist.description
)
for video in playlist.videos {
addToPlaylist(video, playlist: localPlaylist)
}
return localPlaylist
}
/// Updates a playlist's title and description.
func updatePlaylist(_ playlist: LocalPlaylist, title: String, description: String?) {
playlist.title = title