diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-01-20 18:21:47 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-01-20 18:21:47 -0600 |
| commit | daba77d665a7f678540dcf15e2c307eefc456cf2 (patch) | |
| tree | 9bdc417fa83d8bf40a271fa4c438eea7a720faab /src/invidious.cr | |
| parent | a236d7a4e8189972c1c08a7b06644b09dcc89d71 (diff) | |
| parent | 6418d87a63bb121062aab83a30271705d052a31b (diff) | |
| download | invidious-daba77d665a7f678540dcf15e2c307eefc456cf2.tar.gz invidious-daba77d665a7f678540dcf15e2c307eefc456cf2.tar.bz2 invidious-daba77d665a7f678540dcf15e2c307eefc456cf2.zip | |
Merge changes
Diffstat (limited to 'src/invidious.cr')
| -rw-r--r-- | src/invidious.cr | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 270a855b..8591c9d7 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -121,20 +121,30 @@ get "/watch" do |env| next templated "error" end - player_response = JSON.parse(video.info["player_response"]) - + fmt_stream = [] of HTTP::Params video.info["url_encoded_fmt_stream_map"].split(",") do |string| fmt_stream << HTTP::Params.parse(string) end - + fmt_stream.reverse! # We want lowest quality first - + adaptive_fmts = [] of HTTP::Params - video.info["adaptive_fmts"].split(",") do |string| - adaptive_fmts << HTTP::Params.parse(string) + if video.info.has_key?("adaptive_fmts") + video.info["adaptive_fmts"].split(",") do |string| + adaptive_fmts << HTTP::Params.parse(string) + end end - + + rvs = [] of Hash(String, String) + if video.info.has_key?("rvs") + video.info["rvs"].split(",").each do |rv| + rvs << HTTP::Params.parse(rv).to_h + end + end + + player_response = JSON.parse(video.info["player_response"]) + likes = video.html.xpath_node(%q(//button[@title="I like this"]/span)) likes = likes ? likes.content.delete(",").to_i : 1 @@ -150,11 +160,6 @@ get "/watch" do |env| engagement = ((dislikes.to_f + likes.to_f)/views * 100) calculated_rating = (likes.to_f/(likes.to_f + dislikes.to_f) * 4 + 1) - rvs = [] of Hash(String, String) - video.info["rvs"].split(",").each do |rv| - rvs << HTTP::Params.parse(rv).to_h - end - templated "watch" end |
