Skip to content

Instantly share code, notes, and snippets.

@XanderStrike
Last active June 28, 2021 22:09
Show Gist options
  • Save XanderStrike/772686f5d2adedfa3a07c07c13e48f09 to your computer and use it in GitHub Desktop.
Save XanderStrike/772686f5d2adedfa3a07c07c13e48f09 to your computer and use it in GitHub Desktop.
API Glue between JasonHHouse/gaps and tidusjar/Ombi
#!/usr/bin/env ruby
# fillgaps.rb
# Alex Standke 2021
#
# Requirements:
# * You must have Gaps and Ombi set up and running
# * https://github.com/JasonHHouse/gaps
# * https://github.com/tidusjar/Ombi
#
# Use:
# * Modify the four variables below
# * Optionally remove the line at the bottom to avoid being prompted for every movie
# * Run!
GAPS_RSS=""
OMBI_API_KEY=""
OMBI_USER=""
OMBI_URL=""
require 'net/http'
require 'json'
require 'cgi'
def getJSON(url, method: Net::HTTP::Get, body: "")
uri = URI(url)
req = method.new(uri)
req.body = body
req['Accept'] = 'application/json'
req['Content-Type'] = 'application/json'
req['ApiKey'] = OMBI_API_KEY
req['UserName'] = OMBI_USER
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') {|http|
http.request(req)
}
JSON.parse(res.body)
end
def request(movie)
route = "#{OMBI_URL}/api/v1/Search/movie/#{CGI.escape(movie["title"])}"
id = getJSON(route).first["theMovieDbId"]
body = {
theMovieDbId: id,
languageCode: 'en'
}
route = "#{OMBI_URL}/api/v1/Request/movie"
response = getJSON(route, method: Net::HTTP::Post, body: body.to_json)
print response["message"], response["errorMessage"], "\n"
end
someJson = getJSON(GAPS_RSS)
puts "#{someJson.count} missing movies identified"
someJson.each do |movie|
print "Request #{movie['title']}..."
next unless gets.downcase.start_with?('y') # remove this line to add em all
request(movie)
end
@cbirkenbeul
Copy link

Does this script still work?
I ask because my requrest to gaps will not be imported. Or must the ombi url in a specific format?

@XanderStrike
Copy link
Author

I don't know. I kinda regret writing/running it to be honest because it pushed so many requests into Ombi that it became unresponsive and I had to clear the database. Sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment