@@ -390,6 +390,7 @@ get "/embed/:id" do |env|
390
390
end
391
391
392
392
# Playlists
393
+
393
394
get " /playlist" do |env |
394
395
plid = env.params.query[" list" ]?
395
396
if ! plid
@@ -415,6 +416,25 @@ get "/playlist" do |env|
415
416
templated " playlist"
416
417
end
417
418
419
+ get " /mix" do |env |
420
+ rdid = env.params.query[" list" ]?
421
+ if ! rdid
422
+ next env.redirect " /"
423
+ end
424
+
425
+ continuation = env.params.query[" continuation" ]?
426
+ continuation ||= rdid.lchop(" RD" )
427
+
428
+ begin
429
+ mix = fetch_mix(rdid, continuation)
430
+ rescue ex
431
+ error_message = ex.message
432
+ next templated " error"
433
+ end
434
+
435
+ templated " mix"
436
+ end
437
+
418
438
# Search
419
439
420
440
get " /results" do |env |
@@ -2166,12 +2186,13 @@ get "/api/v1/insights/:id" do |env|
2166
2186
end
2167
2187
2168
2188
get " /api/v1/videos/:id" do |env |
2189
+ env.response.content_type = " application/json"
2190
+
2169
2191
id = env.params.url[" id" ]
2170
2192
2171
2193
begin
2172
2194
video = get_video(id, PG_DB , proxies)
2173
2195
rescue ex
2174
- env.response.content_type = " application/json"
2175
2196
error_message = {" error" => ex.message}.to_json
2176
2197
halt env, status_code: 500 , response: error_message
2177
2198
end
@@ -2181,7 +2202,6 @@ get "/api/v1/videos/:id" do |env|
2181
2202
2182
2203
captions = video.captions
2183
2204
2184
- env.response.content_type = " application/json"
2185
2205
video_info = JSON .build do |json |
2186
2206
json.object do
2187
2207
json.field " title" , video.title
@@ -2945,6 +2965,55 @@ get "/api/v1/playlists/:plid" do |env|
2945
2965
response
2946
2966
end
2947
2967
2968
+ get " /api/v1/mixes/:rdid" do |env |
2969
+ env.response.content_type = " application/json"
2970
+
2971
+ rdid = env.params.url[" rdid" ]
2972
+
2973
+ continuation = env.params.query[" continuation" ]?
2974
+ continuation ||= rdid.lchop(" RD" )
2975
+
2976
+ begin
2977
+ mix = fetch_mix(rdid, continuation)
2978
+ rescue ex
2979
+ error_message = {" error" => ex.message}.to_json
2980
+ halt env, status_code: 500 , response: error_message
2981
+ end
2982
+
2983
+ response = JSON .build do |json |
2984
+ json.object do
2985
+ json.field " title" , mix.title
2986
+ json.field " mixId" , mix.id
2987
+
2988
+ json.field " videos" do
2989
+ json.array do
2990
+ mix.videos.each do |video |
2991
+ json.object do
2992
+ json.field " title" , video.title
2993
+ json.field " videoId" , video.id
2994
+ json.field " author" , video.author
2995
+
2996
+ json.field " authorId" , video.ucid
2997
+ json.field " authorUrl" , " /channel/#{ video.ucid } "
2998
+
2999
+ json.field " videoThumbnails" do
3000
+ json.array do
3001
+ generate_thumbnails(json, video.id)
3002
+ end
3003
+ end
3004
+
3005
+ json.field " index" , video.index
3006
+ json.field " lengthSeconds" , video.length_seconds
3007
+ end
3008
+ end
3009
+ end
3010
+ end
3011
+ end
3012
+ end
3013
+
3014
+ response
3015
+ end
3016
+
2948
3017
get " /api/manifest/dash/id/videoplayback" do |env |
2949
3018
env.response.headers[" Access-Control-Allow-Origin" ] = " *"
2950
3019
env.redirect " /videoplayback?#{ env.params.query } "
0 commit comments