aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video/video.service.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-04-17 00:49:04 +0200
committerRigel <sendmemail@rigelk.eu>2018-04-17 01:09:06 +0200
commit244e76a552ef05a5067134b1065d26dd89246d8c (patch)
treea15fcd52bce99797fc9366572fea62a7a44aaabe /client/src/app/shared/video/video.service.ts
parentc36d5a6b98056ef7fec3db43fbee880ee7332dcf (diff)
downloadPeerTube-244e76a552ef05a5067134b1065d26dd89246d8c.tar.gz
PeerTube-244e76a552ef05a5067134b1065d26dd89246d8c.tar.zst
PeerTube-244e76a552ef05a5067134b1065d26dd89246d8c.zip
feature: initial syndication feeds support
Provides rss 2.0, atom 1.0 and json 1.0 feeds for videos (instance and account-wide) on listings and video-watch views. * still lacks redis caching * still lacks lastBuildDate support * still lacks channel-wide support * still lacks semantic annotation (for licenses, NSFW warnings, etc.) * still lacks love ( ˘ ³˘) * RSS: has MRSS support for torrent lists! * RSS: includes the first torrent in an enclosure * JSON: lists all torrents in the 'attachments' object * ATOM: lacking torrent listing support Advances #23 Partial implementation for the accountId generation in the client, which will need a hotfix to add a way to get the proper account id.
Diffstat (limited to 'client/src/app/shared/video/video.service.ts')
-rw-r--r--client/src/app/shared/video/video.service.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 0a8894fd9..009155410 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -8,6 +8,7 @@ import { ResultList } from '../../../../../shared/models/result-list.model'
8import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model' 8import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model'
9import { UserVideoRate } from '../../../../../shared/models/videos/user-video-rate.model' 9import { UserVideoRate } from '../../../../../shared/models/videos/user-video-rate.model'
10import { VideoFilter } from '../../../../../shared/models/videos/video-query.type' 10import { VideoFilter } from '../../../../../shared/models/videos/video-query.type'
11import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum'
11import { VideoRateType } from '../../../../../shared/models/videos/video-rate.type' 12import { VideoRateType } from '../../../../../shared/models/videos/video-rate.type'
12import { VideoUpdate } from '../../../../../shared/models/videos/video-update.model' 13import { VideoUpdate } from '../../../../../shared/models/videos/video-update.model'
13import { environment } from '../../../environments/environment' 14import { environment } from '../../../environments/environment'
@@ -24,6 +25,7 @@ import { objectToFormData } from '@app/shared/misc/utils'
24@Injectable() 25@Injectable()
25export class VideoService { 26export class VideoService {
26 private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/' 27 private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/'
28 private static BASE_FEEDS_URL = environment.apiUrl + '/feeds/videos.'
27 29
28 constructor ( 30 constructor (
29 private authHttp: HttpClient, 31 private authHttp: HttpClient,
@@ -115,6 +117,47 @@ export class VideoService {
115 .catch((res) => this.restExtractor.handleError(res)) 117 .catch((res) => this.restExtractor.handleError(res))
116 } 118 }
117 119
120 baseFeed () {
121 const feed = {}
122
123 for (let item in FeedFormat) {
124 feed[FeedFormat[item]] = VideoService.BASE_FEEDS_URL + item.toLowerCase()
125 }
126
127 return feed
128 }
129
130 getFeed (
131 filter?: VideoFilter
132 ) {
133 let params = this.restService.addRestGetParams(new HttpParams())
134 const feed = this.baseFeed()
135
136 if (filter) {
137 params = params.set('filter', filter)
138 }
139 for (let item in feed) {
140 feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString()
141 }
142
143 return feed
144 }
145
146 getAccountFeed (
147 accountId: number,
148 host?: string
149 ) {
150 let params = this.restService.addRestGetParams(new HttpParams())
151 const feed = this.baseFeed()
152
153 params = params.set('accountId', accountId.toString())
154 for (let item in feed) {
155 feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString()
156 }
157
158 return feed
159 }
160
118 searchVideos ( 161 searchVideos (
119 search: string, 162 search: string,
120 videoPagination: ComponentPagination, 163 videoPagination: ComponentPagination,