|
73 | 73 | get "/twitter" do
|
74 | 74 | return "Insufficient parameters" if params[:q].empty?
|
75 | 75 |
|
76 |
| - if params[:q]["twitter.com/i/"] or params[:q]["twitter.com/who_to_follow/"] |
| 76 | + if params[:q]["twitter.com/i/"] || params[:q]["twitter.com/who_to_follow/"] |
77 | 77 | return "Unsupported url. Sorry."
|
78 | 78 | elsif params[:q]["twitter.com/hashtag/"]
|
79 | 79 | return "This app does not support hashtags. Sorry."
|
80 |
| - elsif /twitter\.com\/(?:#!\/|@)?(?<user>[^\/?#]+)/ =~ params[:q] or /@(?<user>[^\/?#]+)/ =~ params[:q] |
| 80 | + elsif /twitter\.com\/(?:#!\/|@)?(?<user>[^\/?#]+)/ =~ params[:q] || /@(?<user>[^\/?#]+)/ =~ params[:q] |
81 | 81 | # https://twitter.com/#!/infected
|
82 | 82 | # https://twitter.com/infected
|
83 | 83 | # @username
|
|
243 | 243 | else
|
244 | 244 | # it's probably a username
|
245 | 245 | user = params[:q]
|
246 |
| - user = "+#{user}" if user[0] != "+" and !user.numeric? |
| 246 | + user = "+#{user}" if user[0] != "+" && !user.numeric? |
247 | 247 | end
|
248 | 248 |
|
249 | 249 | response = Google.get("/plus/v1/people/#{CGI.escape(user)}")
|
|
291 | 291 | response = Vimeo.get("/videos/#{video_id}")
|
292 | 292 | raise(VimeoError, response) if !response.success?
|
293 | 293 | user_id = response.json["user"]["uri"][/\d+/]
|
294 |
| - elsif /vimeo\.com\/(?:channels\/)?(?<user>[^\/?&#]+)/ =~ params[:q] or user = params[:q] |
| 294 | + elsif /vimeo\.com\/(?:channels\/)?(?<user>[^\/?&#]+)/ =~ params[:q] || user = params[:q] |
295 | 295 | # it's probably a channel name
|
296 | 296 | response = Vimeo.get("/users", query: { query: user })
|
297 | 297 | raise(VimeoError, response) if !response.success?
|
|
420 | 420 | # This is not the best quality of the picture, but it will have to do
|
421 | 421 | url = CGI.unescapeHTML($&)
|
422 | 422 | end
|
423 |
| - if /<title[^>]*>(?<title>[^<]+)<\/title>/ =~ response.body and /data-utime="(?<utime>\d+)"/ =~ response.body |
| 423 | + if /<title[^>]*>(?<title>[^<]+)<\/title>/ =~ response.body && /data-utime="(?<utime>\d+)"/ =~ response.body |
424 | 424 | title = title.force_encoding("UTF-8").gsub(" | Facebook", "")
|
425 | 425 | created_time = Time.at(utime.to_i)
|
426 | 426 | fn = "#{created_time.to_date} - #{title}.#{url.url_ext}".to_filename
|
|
467 | 467 | # Filter posts if with=uid is supplied (property only exists on posts)
|
468 | 468 | if params[:with]
|
469 | 469 | ids = params[:with].split(",")
|
470 |
| - @data.select! { |post| post["with_tags"] and post["with_tags"]["data"].any? { |tag| ids.include?(tag["id"]) } } |
| 470 | + @data.select! { |post| post["with_tags"] && post["with_tags"]["data"].any? { |tag| ids.include?(tag["id"]) } } |
471 | 471 | elsif params.has_key?(:with)
|
472 | 472 | # If with is specified but is nil, then we just want to get posts that include someone else
|
473 | 473 | @data.select! { |post| post["with_tags"] }
|
|
477 | 477 | @data.each do |post|
|
478 | 478 | if post["properties"]
|
479 | 479 | post["properties"].each do |prop|
|
480 |
| - if prop["name"] == "Length" and /^(?<m>\d+):(?<s>\d+)$/ =~ prop["text"] |
| 480 | + if prop["name"] == "Length" && /^(?<m>\d+):(?<s>\d+)$/ =~ prop["text"] |
481 | 481 | post["length"] = 60*m.to_i + s.to_i
|
482 | 482 | end
|
483 | 483 | end
|
|
703 | 703 | uri = Addressable::URI.parse(response.json["location"])
|
704 | 704 | return "URL does not resolve to a user." if !uri.path.start_with?("/users/")
|
705 | 705 | id = uri.path[/\d+/]
|
706 |
| - elsif response.code == 404 and username.numeric? |
| 706 | + elsif response.code == 404 && username.numeric? |
707 | 707 | response = Soundcloud.get("/users/#{username}")
|
708 | 708 | return "Can't find a user with that id. Sorry." if response.code == 404
|
709 | 709 | raise(SoundcloudError, response) if !response.success?
|
|
822 | 822 | if /clips\.twitch\.tv\/(?:embed\?clip=)?(?<clip_slug>[^?&#]+)/ =~ params[:url]
|
823 | 823 | # https://clips.twitch.tv/majinphil/UnusualClamRaccAttack
|
824 | 824 | # https://clips.twitch.tv/embed?clip=majinphil/UnusualClamRaccAttack&autoplay=false
|
825 |
| - elsif /twitch\.tv\/videos\/(?<vod_id>\d+)/ =~ params[:url] or /twitch\.tv\/(?:[^\/]+)\/v\/(?<vod_id>\d+)/ =~ params[:url] or /(^|v)(?<vod_id>\d+)/ =~ params[:url] |
| 825 | + elsif /twitch\.tv\/videos\/(?<vod_id>\d+)/ =~ params[:url] || /twitch\.tv\/(?:[^\/]+)\/v\/(?<vod_id>\d+)/ =~ params[:url] || /(^|v)(?<vod_id>\d+)/ =~ params[:url] |
826 | 826 | # https://www.twitch.tv/videos/25133028
|
827 | 827 | # https://www.twitch.tv/gamesdonequick/v/34377308?t=53m40s
|
828 | 828 | # https://player.twitch.tv/?video=v103620362
|
|
870 | 870 | if /clips\.twitch\.tv\/(?:embed\?clip=)?(?<clip_slug>[^?&#]+)/ =~ params[:url]
|
871 | 871 | # https://clips.twitch.tv/majinphil/UnusualClamRaccAttack
|
872 | 872 | # https://clips.twitch.tv/embed?clip=majinphil/UnusualClamRaccAttack&autoplay=false
|
873 |
| - elsif /twitch\.tv\/videos\/(?<vod_id>\d+)/ =~ params[:url] or /twitch\.tv\/(?:[^\/]+)\/v\/(?<vod_id>\d+)/ =~ params[:url] or /(^|v)(?<vod_id>\d+)/ =~ params[:url] |
| 873 | + elsif /twitch\.tv\/videos\/(?<vod_id>\d+)/ =~ params[:url] || /twitch\.tv\/(?:[^\/]+)\/v\/(?<vod_id>\d+)/ =~ params[:url] || /(^|v)(?<vod_id>\d+)/ =~ params[:url] |
874 | 874 | # https://www.twitch.tv/videos/25133028
|
875 | 875 | # https://www.twitch.tv/gamesdonequick/v/34377308?t=53m40s
|
876 | 876 | # https://player.twitch.tv/?video=v103620362
|
|
1029 | 1029 | get "/dailymotion" do
|
1030 | 1030 | return "Insufficient parameters" if params[:q].empty?
|
1031 | 1031 |
|
1032 |
| - if /dailymotion\.com\/video\/(?<video_id>[a-zA-Z0-9]+)/ =~ params[:q] or /dai\.ly\/(?<video_id>[a-zA-Z0-9]+)/ =~ params[:q] |
| 1032 | + if /dailymotion\.com\/video\/(?<video_id>[a-zA-Z0-9]+)/ =~ params[:q] || /dai\.ly\/(?<video_id>[a-zA-Z0-9]+)/ =~ params[:q] |
1033 | 1033 | # http://www.dailymotion.com/video/x3r4xy2_recut-9-cultural-interchange_fun
|
1034 | 1034 | # http://www.dailymotion.com/video/k1ZotianZxwzm6fmny2
|
1035 | 1035 | # http://dai.ly/x4bzwj4?start=60
|
|
1089 | 1089 | # https://www.reddit.com/r/aww
|
1090 | 1090 | redirect "/imgur/r/#{subreddit}#{"?#{params[:type]}" if !params[:type].empty?}"
|
1091 | 1091 | return
|
1092 |
| - elsif /(?<username>[a-zA-Z0-9]+)\.imgur\.com/ =~ params[:q] and username != "i" |
| 1092 | + elsif /(?<username>[a-zA-Z0-9]+)\.imgur\.com/ =~ params[:q] && username != "i" |
1093 | 1093 | # https://thebookofgray.imgur.com/
|
1094 | 1094 | elsif /imgur\.com\/(gallery\/)?(?<image_id>[a-zA-Z0-9]+)/ =~ params[:q]
|
1095 | 1095 | # https://imgur.com/NdyrgaE
|
|
1137 | 1137 | # can't use user_id in this request unfortunately
|
1138 | 1138 | response = Imgur.get("/account/#{@username}/submissions")
|
1139 | 1139 | end
|
1140 |
| - raise(ImgurError, response) if !response.success? or response.body.empty? |
| 1140 | + raise(ImgurError, response) if !response.success? || response.body.empty? |
1141 | 1141 | @data = response.json["data"]
|
1142 | 1142 |
|
1143 | 1143 | if params[:animated]
|
|
0 commit comments