Skip to content

Commit aa9e33e

Browse files
committed
Fixed AllPossibleHostPlaylistsResponse returning a bad playlist id.
1 parent bdd0279 commit aa9e33e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/YouTubeKit/YouTubeResponseTypes/AuthenticatedResponses/HistoryActions/HistoryResponse.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct HistoryResponse: AuthenticatedResponse {
2727
/// ```swift
2828
/// var videosAndTime = [("Today", [A few videos]), ("Yesterday", [A few videos too])]
2929
/// ```
30-
public var videosAndTime: [(String, [(YTVideo, suppressToken: String?)])] = []
30+
public var videosAndTime: [(groupTitle: String, videosArray: [(YTVideo, suppressToken: String?)])] = []
3131

3232
/// Title of the playlist.
3333
public var title: String?

Sources/YouTubeKit/YouTubeResponseTypes/AuthenticatedResponses/PlaylistsActions/AllPossibleHostPlaylistsResponse.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ public struct AllPossibleHostPlaylistsResponse: AuthenticatedResponse {
2626
if content["addToPlaylistRenderer"].exists() {
2727
for playlistJSON in content["addToPlaylistRenderer"]["playlists"].arrayValue {
2828
if let playlistId = playlistJSON["playlistAddToOptionRenderer"]["playlistId"].string, let containsVideo = playlistJSON["playlistAddToOptionRenderer"]["containsSelectedVideos"].string {
29-
var playlist = YTPlaylist(playlistId: playlistId.hasPrefix("VL") ? playlistId : "VL" + playlistId)
29+
30+
// 2 ways of creating a playlist, YouTube changed (temporarily?) the system by removing the VL prefix at the beginning of the playlist's id.
31+
//var playlist = YTPlaylist(playlistId: playlistId.hasPrefix("VL") ? playlistId : "VL" + playlistId)
32+
var playlist = YTPlaylist(playlistId: playlistId.hasPrefix("VL") ? String(playlistId.dropFirst(2)) : playlistId)
33+
34+
3035
playlist.title = playlistJSON["playlistAddToOptionRenderer"]["title"]["simpleText"].string
3136
playlist.privacy = YTPrivacy(rawValue: playlistJSON["playlistAddToOptionRenderer"]["privacy"].stringValue)
3237
toReturn.playlistsAndStatus.append((playlist, containsVideo == "ALL"))

0 commit comments

Comments
 (0)