def youtube_filter(s)
loc = Utils.check_location(s, /youtube\.com/)
return nil unless loc
- if s[:text].include? '<div id="vidTitle">'
+ if s[:text].include? '<div id="watch-vid-title">'
vid = @bot.filter(:"youtube.video", s)
return nil unless vid
content = _("Category: %{cat}. Rating: %{rating}. Author: %{author}. Duration: %{duration}. %{views} views, faved %{faves} times. %{desc}") % vid
end
# otherwise, just grab the proper div
if defined? Hpricot
- content = (Hpricot(s[:text])/"#mainContent").to_html.ircify_html
+ content = (Hpricot(s[:text])/".watch-video-desc").to_html.ircify_html
end
# suboptimal, but still better than the default HTML info extractor
- content ||= /<div id="mainContent"[^>]*>/.match(s[:text]).post_match.ircify_html
+ dm = /<div\s+class="watch-video-desc"[^>]*>/.match(s[:text])
+ content ||= dm ? dm.post_match.ircify_html : '(no description found)'
return {:title => s[:text].ircify_html_title, :content => content}
end
vid[:desc].gsub!(/\s+/m, " ")
end
if secs = vid[:seconds]
- mins, secs = secs.divmod 60
- hours, mins = mins.divmod 60
- if hours > 0
- vid[:duration] = "%s:%s:%s" % [hours, mins, secs]
- elsif mins > 0
- vid[:duration] = "%s'%s\"" % [mins, secs]
- else
- vid[:duration] = "%ss" % [secs]
- end
+ vid[:duration] = Utils.secs_to_short(secs)
else
vid[:duration] = _("unknown duration")
end
:format => fmt
}.delete_if { |k, v| v.nil? }
if seconds
- mins, secs = seconds.divmod 60
- hours, mins = mins.divmod 60
- if hours > 0
- vid[:formats].last[:duration] = "%s:%s:%s" % [hours, mins, secs]
- elsif mins > 0
- vid[:formats].last[:duration] = "%s'%s\"" % [mins, secs]
- else
- vid[:formats].last[:duration] = "%ss" % [secs]
- end
+ vid[:formats].last[:duration] = Utils.secs_to_short(seconds)
else
vid[:formats].last[:duration] = _("unknown duration")
end