diff app/views/tweets/_tweet.html.erb @ 178:38598ae5a8f6

Sort video url by bitrate
author nanaya <me@nanaya.pro>
date Sat, 13 Oct 2018 14:26:25 +0900
parents d35dbc09bd83
children 7b1bdf697063
line wrap: on
line diff
--- a/app/views/tweets/_tweet.html.erb	Sat Oct 13 00:48:05 2018 +0900
+++ b/app/views/tweets/_tweet.html.erb	Sat Oct 13 14:26:25 2018 +0900
@@ -37,7 +37,11 @@
           <%= image_tag "#{media.media_url_https}:small", :alt => "attachment #{i + 1}" -%>
         <% end %>
       <% elsif media.is_a? Twitter::Media::Video %>
-        <%= video_tag media.video_info.variants.map(&:url), width: '100%', controls: true %>
+        <%= video_tag media.video_info.variants
+          .select { |i| i.bitrate.is_a? Integer }
+          .sort_by { |i| -i.bitrate }
+          .map(&:url), width: '100%', controls: true
+        %>
       <% end %>
     <% end %>
   </p>