Skip to content

Instantly share code, notes, and snippets.

@Sutto
Created April 6, 2011 10:20
Show Gist options
  • Save Sutto/905435 to your computer and use it in GitHub Desktop.
Save Sutto/905435 to your computer and use it in GitHub Desktop.
Moved a folder? Clean your sickbeard library...
require 'rubygems'
require 'sequel'
database = Sequel.connect('sqlite://sickbeard.db')
database[:tv_episodes].select(:location, :episode_id).exclude(:location => "").each do |show|
if !File.file?(show[:location])
database[:tv_episodes].filter(:episode_id => show[:episode_id]).delete
end
end
database[:tv_shows].select(:show_name, :tvdb_id, :location).each do |show|
if !File.directory?(show[:location])
puts "#{show[:show_name]} - #{show[:tvdb_id]}"
database[:tv_episodes].filter(:showid => show[:tvdb_id]).delete
database[:tv_shows].filter(:tvdb_id => show[:tvdb_id]).delete
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment