diff --git a/app/VideoWeb/Invidious.class.st b/app/VideoWeb/Invidious.class.st index 87994a9..6a5f331 100644 --- a/app/VideoWeb/Invidious.class.st +++ b/app/VideoWeb/Invidious.class.st @@ -83,9 +83,10 @@ Invidious >> authorIdForVideo: aString [ { #category : #accessing } Invidious >> channel: authorId [ - | queryURL | + | queryURL dataDict | queryURL := self uri asString, 'api/v1/channels/', authorId . - ^ STONJSON fromString: queryURL asUrl retrieveContents + dataDict := STONJSON fromString: queryURL asUrl retrieveContents. + ^ VideoChannel new fromDictionary: dataDict ] { #category : #accessing } diff --git a/app/VideoWeb/VideoChannel.class.st b/app/VideoWeb/VideoChannel.class.st index 370283d..bd6c988 100644 --- a/app/VideoWeb/VideoChannel.class.st +++ b/app/VideoWeb/VideoChannel.class.st @@ -66,6 +66,23 @@ VideoChannel >> description: anObject [ description := anObject ] +{ #category : #accessing } +VideoChannel >> fromDictionary: aDictionary [ + | lastestVideosArray | + self author: (aDictionary at: 'author'); + authorId: (aDictionary at: 'authorId'); + authorThumbnails: (aDictionary at: 'authorThumbnails'); + description: (aDictionary at: 'description'); + isFamilyFriendly: (aDictionary at: 'isFamilyFriendly'); + relatedChannels: (aDictionary at: 'relatedChannels'); + subscribersCount: (aDictionary at: 'subCount'); + totalViews: (aDictionary at: 'totalViews'). + lastestVideosArray := (aDictionary at: 'latestVideos' ). + lastestVideosArray do: [ :videoData | + self latestVideos add: (WebVideo new fromDictionary: videoData ) ]. + ^ self +] + { #category : #accessing } VideoChannel >> isFamilyFriendly [ ^ isFamilyFriendly @@ -78,7 +95,7 @@ VideoChannel >> isFamilyFriendly: anObject [ { #category : #accessing } VideoChannel >> latestVideos [ - ^ latestVideos + ^ latestVideos ifNil: [ latestVideos := OrderedCollection new] ] { #category : #accessing } @@ -86,6 +103,13 @@ VideoChannel >> latestVideos: anObject [ latestVideos := anObject ] +{ #category : #accessing } +VideoChannel >> printOn: aStream [ + super printOn: aStream. + aStream + nextPutAll: ' ( ', self author, ' | ', self authorId, ' | ', self description, ' )' +] + { #category : #accessing } VideoChannel >> relatedChannels [ ^ relatedChannels diff --git a/app/VideoWeb/WebVideo.class.st b/app/VideoWeb/WebVideo.class.st index 8326a4c..64261fc 100644 --- a/app/VideoWeb/WebVideo.class.st +++ b/app/VideoWeb/WebVideo.class.st @@ -65,7 +65,7 @@ WebVideo >> fromDictionary: aDictionary [ authorId: (aDictionary at: 'authorId'); lengthSeconds: (aDictionary at: 'lengthSeconds'); videoThumbnails: (aDictionary at: 'videoThumbnails'); - likeCount: (aDictionary at: 'likeCount'). + likeCount: (aDictionary at: 'likeCount' ifAbsentPut: [ nil ]). ] { #category : #accessing }