Skip to content

Commit

Permalink
Fixed channel extraction.
Browse files Browse the repository at this point in the history
  • Loading branch information
b5i committed Aug 26, 2024
1 parent f75a838 commit be35666
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/YouTubeKit/BaseStructs/YTChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public struct YTChannel: YTSearchResult, YouTubeChannel {
/// Inititalize a new ``YTSearchResultType/Channel-swift.struct`` instance to put the informations in it.
var channel = YTChannel(channelId: channelId)
channel.name = json["title"]["simpleText"].string
if json["navigationEndpoint"]["browseEndpoint"]["canonicalBaseUrl"].stringValue.contains("/c/") { // special channel json with no handle
if json["navigationEndpoint"]["browseEndpoint"]["canonicalBaseUrl"].stringValue.contains("/c/") || json["subscriberCountText"]["simpleText"].string?.hasPrefix("@") != true { // special channel json with no handle
channel.subscriberCount = json["subscriberCountText"]["simpleText"].string
channel.videoCount = json["videoCountText"]["runs"].array?.map {$0["text"].stringValue}.reduce("", +) ?? json["videoCountText"]["simpleText"].string
} else {
channel.handle = json["subscriberCountText"]["simpleText"].string
channel.subscriberCount = json["videoCountText"]["simpleText"].string
channel.subscriberCount = json["videoCountText"]["runs"].array?.map {$0["text"].stringValue}.reduce("", +) ?? json["videoCountText"]["simpleText"].string
}
YTThumbnail.appendThumbnails(json: json["thumbnail"], thumbnailList: &channel.thumbnails)

Expand Down

0 comments on commit be35666

Please sign in to comment.