Improved channel data adquisition from API and latest videos.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-01-09 10:44:35 -05:00
parent 8219ae207f
commit 8ae222297a
3 changed files with 29 additions and 4 deletions

View File

@ -83,9 +83,10 @@ Invidious >> authorIdForVideo: aString [
{ #category : #accessing } { #category : #accessing }
Invidious >> channel: authorId [ Invidious >> channel: authorId [
| queryURL | | queryURL dataDict |
queryURL := self uri asString, 'api/v1/channels/', authorId . 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 } { #category : #accessing }

View File

@ -66,6 +66,23 @@ VideoChannel >> description: anObject [
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 } { #category : #accessing }
VideoChannel >> isFamilyFriendly [ VideoChannel >> isFamilyFriendly [
^ isFamilyFriendly ^ isFamilyFriendly
@ -78,7 +95,7 @@ VideoChannel >> isFamilyFriendly: anObject [
{ #category : #accessing } { #category : #accessing }
VideoChannel >> latestVideos [ VideoChannel >> latestVideos [
^ latestVideos ^ latestVideos ifNil: [ latestVideos := OrderedCollection new]
] ]
{ #category : #accessing } { #category : #accessing }
@ -86,6 +103,13 @@ VideoChannel >> latestVideos: anObject [
latestVideos := anObject latestVideos := anObject
] ]
{ #category : #accessing }
VideoChannel >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: ' ( ', self author, ' | ', self authorId, ' | ', self description, ' )'
]
{ #category : #accessing } { #category : #accessing }
VideoChannel >> relatedChannels [ VideoChannel >> relatedChannels [
^ relatedChannels ^ relatedChannels

View File

@ -65,7 +65,7 @@ WebVideo >> fromDictionary: aDictionary [
authorId: (aDictionary at: 'authorId'); authorId: (aDictionary at: 'authorId');
lengthSeconds: (aDictionary at: 'lengthSeconds'); lengthSeconds: (aDictionary at: 'lengthSeconds');
videoThumbnails: (aDictionary at: 'videoThumbnails'); videoThumbnails: (aDictionary at: 'videoThumbnails');
likeCount: (aDictionary at: 'likeCount'). likeCount: (aDictionary at: 'likeCount' ifAbsentPut: [ nil ]).
] ]
{ #category : #accessing } { #category : #accessing }