Skip to content

Instantly share code, notes, and snippets.

@Coopeh
Forked from Sutto/sickbeard-clean-library.rb
Last active April 4, 2016 17:47
Show Gist options
  • Save Coopeh/f5737bfbfbcdc1207a7c854b38cb95be to your computer and use it in GitHub Desktop.
Save Coopeh/f5737bfbfbcdc1207a7c854b38cb95be to your computer and use it in GitHub Desktop.
Moved a folder? Clean your sickbeard library... Updated to work with imdb_id instead of tvdb_id
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, :imdb_id, :location).each do |show|
if !File.directory?(show[:location])
puts "#{show[:show_name]} - #{show[:imdb_id]}"
database[:tv_episodes].filter(:showid => show[:imdb_id]).delete
database[:tv_shows].filter(:imdb_id => show[:imdb_id]).delete
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment