Created
April 16, 2009 23:00
-
-
Save itspriddle/96740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'activerecord' | |
DB_HOST = 'localhost' | |
DB_USER = 'username' | |
DB_PASS = 'password' | |
DB_NAME = 'database' | |
class Movie < ActiveRecord::Base | |
class << self | |
def connect_db | |
return if self.table_name == 'movies' | |
conf = {'username' => DB_USER, 'host' => DB_HOST, 'password' => DB_PASS, 'database' => DB_NAME, 'adapter' => 'mysql'} | |
self.establish_connection(conf) | |
self | |
end | |
def scan_for_new | |
Dir['/media/iptv/hd2/movies/**'].each do |path| | |
Movie.create({:filename => path}) | |
end | |
end | |
end | |
end | |
Movie.connect_db | |
Movie.scan_for_new | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment