diff options
| author | Omar Roth <omarroth@hotmail.com> | 2019-04-11 12:08:43 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2019-04-11 12:08:43 -0500 |
| commit | 5e141e869d0817ab179e287967451a7def135674 (patch) | |
| tree | 1de5aca986596949aa5e7bf51f4c8ed2edd78df3 /src | |
| parent | 611555514c31230bcdc1980e0b110cca057b3b72 (diff) | |
| download | invidious-5e141e869d0817ab179e287967451a7def135674.tar.gz invidious-5e141e869d0817ab179e287967451a7def135674.tar.bz2 invidious-5e141e869d0817ab179e287967451a7def135674.zip | |
Add subtitles to download widget
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 14 | ||||
| -rw-r--r-- | src/invidious/views/watch.ecr | 5 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 2a314218..9a2bd260 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2722,6 +2722,11 @@ get "/api/v1/captions/:id" do |env| END_CUE end + if title = env.params.query["title"]? + # https://blog.fastmail.com/2011/06/24/download-non-english-filenames/ + env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.escape(title)}\"; filename*=UTF-8''#{URI.escape(title)}" + end + webvtt end @@ -4214,11 +4219,18 @@ end get "/latest_version" do |env| if env.params.query["download_widget"]? download_widget = JSON.parse(env.params.query["download_widget"]) + id = download_widget["id"].as_s - itag = download_widget["itag"].as_s title = download_widget["title"].as_s + + if label = download_widget["label"]? + env.redirect "/api/v1/captions/#{id}?label=#{label}&title=#{title}" + next + else + itag = download_widget["itag"].as_s local = "true" end + end id ||= env.params.query["id"]? itag ||= env.params.query["itag"]? diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 18cbdef7..bd49709e 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -79,6 +79,11 @@ <%= itag_to_metadata?(option["itag"]).try &.["height"]? || "~240" %>p - <%= option["type"].split(";")[0] %> </option> <% end %> + <% captions.each do |caption| %> + <option value='{"id":"<%= video.id %>","label":"<%= caption.name.simpleText %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= caption.languageCode %>.vtt"}'> + <%= translate(locale, "Subtitles - `x` (.vtt)", caption.name.simpleText) %> + </option> + <% end %> </select> </div> |
