import { SearchService } from './search.service'
import { AdvancedSearch } from './advanced-search.model'
-const logger = debug('peertube:search:FindInBulkService')
+const debugLogger = debug('peertube:search:FindInBulkService')
type BulkObservables <P extends number | string, R> = {
notifier: Subject<P>
}
getVideo (uuid: string): Observable<Video> {
- logger('Schedule video fetch for uuid %s.', uuid)
+ debugLogger('Schedule video fetch for uuid %s.', uuid)
return this.getData({
observableObject: this.getVideoInBulk,
- finder: v => v.uuid === uuid,
+ finder: v => v.uuid === uuid || v.shortUUID === uuid,
param: uuid
})
}
getChannel (handle: string): Observable<VideoChannel> {
- logger('Schedule channel fetch for handle %s.', handle)
+ debugLogger('Schedule channel fetch for handle %s.', handle)
return this.getData({
observableObject: this.getChannelInBulk,
}
getPlaylist (uuid: string): Observable<VideoPlaylist> {
- logger('Schedule playlist fetch for uuid %s.', uuid)
+ debugLogger('Schedule playlist fetch for uuid %s.', uuid)
return this.getData({
observableObject: this.getPlaylistInBulk,
map(result => result.response.data),
map(data => data.find(finder))
)
- .subscribe(result => {
- if (!result) {
- obs.error(new Error($localize`Element ${param} not found`))
- } else {
+ .subscribe({
+ next: result => {
+ if (!result) {
+ obs.error(new Error($localize`Element ${param} not found`))
+ return
+ }
+
obs.next(result)
obs.complete()
- }
+ },
+
+ error: err => obs.error(err)
})
observableObject.notifier.next(param)
}
private getVideosInBulk (uuids: string[]) {
- logger('Fetching videos %s.', uuids.join(', '))
+ debugLogger('Fetching videos %s.', uuids.join(', '))
return this.searchService.searchVideos({
uuids,
}
private getChannelsInBulk (handles: string[]) {
- logger('Fetching channels %s.', handles.join(', '))
+ debugLogger('Fetching channels %s.', handles.join(', '))
return this.searchService.searchVideoChannels({
handles,
}
private getPlaylistsInBulk (uuids: string[]) {
- logger('Fetching playlists %s.', uuids.join(', '))
+ debugLogger('Fetching playlists %s.', uuids.join(', '))
return this.searchService.searchVideoPlaylists({
uuids,