movie-manager-gem 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +23 -7
- data/bin/movie-manager-gem +9 -5
- data/lib/movie-manager-gem.rb +78 -181
- data/lib/movie-manager-gem/version.rb +1 -1
- data/movie-manager-gem.gemspec +5 -5
- metadata +24 -25
- data/movies.db +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331124dd875337069ce6281ebca523f018458475
|
4
|
+
data.tar.gz: d29a7a3b68d556e5e2b11546d9929b61d426356f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ddade648b0a60fe1cdd5788d9acde8aeda96009eaa7e1f949d2533d4bdb9f2dd0640f9adea86071afecf07b818248485943f8ee129cc956e506a5a7b44bd6c7
|
7
|
+
data.tar.gz: 28d3379c8427865772d8e4979fba8166cf8a74681854810d5bbbaa103c71e25f15dad7a392331688bfcccaab28518fa87df5bd7b0660c3a5c6cff41667c4c734
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
DH Movie Manager is a command line tool for organizing local movie files.
|
4
4
|
|
5
|
-
DHMM finds local movie files, queies
|
5
|
+
DHMM finds local movie files, queies IMDB, and stores the data in a sqlite3 database that you can use to run commands. Search for specific actors, directors, and genres. Filter results by audience score. Update your filenames to reflect the correct title.
|
6
|
+
|
6
7
|
Feeling indecisive? use the 'play unseen [genre]' command to play a random movie that suits your mood.
|
7
8
|
|
8
9
|
## Installation
|
@@ -19,16 +20,23 @@ Or install it yourself as:
|
|
19
20
|
|
20
21
|
$ gem install movie_manager_gem
|
21
22
|
|
22
|
-
##
|
23
|
+
## Getting Started
|
24
|
+
|
25
|
+
From your home directory, simply run:
|
26
|
+
|
27
|
+
movie-manager-gem
|
23
28
|
|
24
|
-
|
25
|
-
|
29
|
+
## Usage
|
30
|
+
Below are a list of valid commands. Brackets indicate user input (don't use brackets when inputing arguments).
|
26
31
|
|
27
|
-
|
32
|
+
If this is the first time using DHMM, you will be asked to tell the program where to find your movie files (trust me when I say you don't want the program looking through your entire harddrive). Using the 'start' command, drag and drop in the folder that holds your movies to add them to the database:
|
28
33
|
|
29
|
-
To begin, drag and drop in the folder that holds your movies to add them to the database:
|
30
34
|
start [file path]
|
31
35
|
|
36
|
+
See information about a particular movie:
|
37
|
+
|
38
|
+
info [title]
|
39
|
+
|
32
40
|
Return a list of actors with the given name:
|
33
41
|
|
34
42
|
search actor [name] [rating (optional)]
|
@@ -43,7 +51,7 @@ Return a list of movies with the given genre:
|
|
43
51
|
|
44
52
|
Return a list of all movies with a RottenTomatoes Audience Score above [rating]:
|
45
53
|
|
46
|
-
search movies [rating]
|
54
|
+
search movies [rating]
|
47
55
|
|
48
56
|
|
49
57
|
Play a movie with the given title:
|
@@ -69,6 +77,14 @@ Tips:
|
|
69
77
|
- Partial searches (eg com vs comedy) can be used
|
70
78
|
- Searches can be multiple words (eg 'search actor Gary Oldman 60')
|
71
79
|
|
80
|
+
## New in Version 0.0.3
|
81
|
+
- Switched from Rotten Tomatoes to IMDB. This allows for accurate results from less precise file names.
|
82
|
+
- IMPORTANT! Changed database structure to include length, summary, and IMDB's ratings. This means we have to re-index your movies.
|
83
|
+
- Added 'info' function to see all the relevant info about a given movie
|
84
|
+
- Updated /bin file to include this functionality
|
85
|
+
- Added versions to gem requirements, generally made code a little cleaner (removing empty methods, unnecessary comments)
|
86
|
+
- Improved feedback when unable to find movies of a given genre above a given rating
|
87
|
+
|
72
88
|
## Contributing
|
73
89
|
|
74
90
|
1. Fork it ( https://github.com/hammeiam/movie_manager_gem/fork )
|
data/bin/movie-manager-gem
CHANGED
@@ -20,25 +20,28 @@ while true
|
|
20
20
|
if command[0] == 'start'
|
21
21
|
session.find_files_in(command[1..-1].join.gsub("\\", " "))
|
22
22
|
|
23
|
+
elsif command[0] == 'info'
|
24
|
+
session.display_movie_info(command[1..-1].join(" "))
|
25
|
+
|
23
26
|
elsif command[0] == 'search'
|
24
27
|
if command[1] == 'movies'
|
25
|
-
session.list_all_movies(command[2]?command[2]
|
28
|
+
session.list_all_movies(command[2] ? command[2].to_f : -1) # sets a default value of -1 for empty rating arguments
|
26
29
|
|
27
30
|
elsif command[1] == 'actor'
|
28
31
|
if command[-1] =~ /[0-9]+/
|
29
|
-
session.list_movies_with_actor(command[2..-2].join(" "), command[-1])
|
32
|
+
session.list_movies_with_actor(command[2..-2].join(" "), command[-1].to_f)
|
30
33
|
else
|
31
34
|
session.list_movies_with_actor(command[2..-1].join(" "))
|
32
35
|
end
|
33
36
|
elsif command[1] == 'director'
|
34
37
|
if command[-1] =~ /[0-9]+/
|
35
|
-
session.list_movies_with_director(command[2..-2].join(" "), command[-1])
|
38
|
+
session.list_movies_with_director(command[2..-2].join(" "), command[-1].to_f)
|
36
39
|
else
|
37
40
|
session.list_movies_with_director(command[2..-1].join(" "))
|
38
41
|
end
|
39
42
|
elsif command[1] == 'genre'
|
40
43
|
if command[-1] =~ /[0-9]+/
|
41
|
-
session.list_movies_by_genre(command[2..-2].join(" "), command[-1])
|
44
|
+
session.list_movies_by_genre(command[2..-2].join(" "), command[-1].to_f)
|
42
45
|
else
|
43
46
|
session.list_movies_by_genre(command[2..-1].join(" "))
|
44
47
|
end
|
@@ -47,7 +50,7 @@ while true
|
|
47
50
|
elsif command[0] == 'play'
|
48
51
|
if command[1] == 'unseen' # distinguish btw the 'play' and 'play unseen genre' functions
|
49
52
|
if command[-1] =~ /[0-9]+/
|
50
|
-
session.play_unseen_genre(command[2..-2].join(" "), command[-1])
|
53
|
+
session.play_unseen_genre(command[2..-2].join(" "), command[-1].to_f)
|
51
54
|
else
|
52
55
|
session.play_unseen_genre(command[2..-1].join(" "))
|
53
56
|
end
|
@@ -68,6 +71,7 @@ while true
|
|
68
71
|
puts ""
|
69
72
|
puts "'start [file path]' drag and drop in the folder that holds your movies to add them to the database"
|
70
73
|
puts ""
|
74
|
+
puts "'info [title]' returns information about a movie"
|
71
75
|
puts "'search actor [name] [rating (optional)]' returns a list of actors with the given name"
|
72
76
|
puts "'search director [name] [rating (optional)]' returns a list of directors with the given name"
|
73
77
|
puts "'search genre [genre] [rating (optional)]' returns a list of movies with the given genre"
|
data/lib/movie-manager-gem.rb
CHANGED
@@ -4,20 +4,15 @@ module MovieManagerGem
|
|
4
4
|
### DH Searcher ###
|
5
5
|
class Finder
|
6
6
|
require 'rubygems'
|
7
|
-
require '
|
7
|
+
require 'imdb'
|
8
8
|
require 'sequel'
|
9
9
|
require 'thread'
|
10
10
|
require 'sqlite3' # sqlite3 implementation
|
11
11
|
# require 'pg' # postgres implementation
|
12
12
|
|
13
|
-
include RottenTomatoes
|
14
|
-
|
15
13
|
def initialize()
|
16
|
-
# input Rotentomatoes api key
|
17
|
-
Rotten.api_key = "9t2nx4s6bb62s8hvjftx8sx4"
|
18
|
-
|
19
14
|
# start database
|
20
|
-
@@DB = Sequel.sqlite('
|
15
|
+
@@DB = Sequel.sqlite(File.expand_path('~/.movie_manager_003.db')) # sqlite3 implementation
|
21
16
|
# @@DB = Sequel.postgres('testdb', :host=>'localhost', :user=>'David', :password=>'password') # postgres implementation
|
22
17
|
|
23
18
|
# create tables within database
|
@@ -50,23 +45,12 @@ module MovieManagerGem
|
|
50
45
|
@movies_dataset.first
|
51
46
|
end
|
52
47
|
|
53
|
-
def refine_unfound_movie_titles
|
54
|
-
# for n in movies where original title == title
|
55
|
-
# puts "What should the title of #{title} be?"
|
56
|
-
# title = gets.chop
|
57
|
-
end
|
58
|
-
|
59
48
|
def update_file_names
|
60
|
-
# find where movie titles =0. 0=unchecked, 1=correct
|
61
|
-
# for each, ask if title is correct
|
62
|
-
# if yes, dataset.where(:id => each[:id]).update(:correct_filename => 1)
|
63
|
-
# else
|
64
49
|
incorrect_names = @movies_dataset.select(:id, :original_title, :title).where(:correct_filename => 0).all
|
65
50
|
incorrect_names.each do |name|
|
66
51
|
puts "Is \"#{name[:title]}\" the correct title for \"#{File.basename(name[:original_title],".*")}\"? \n y/n"
|
67
52
|
print '> '
|
68
53
|
response = $stdin.gets.chomp.downcase
|
69
|
-
#name[:id] == basename(name[:original_title],".*")
|
70
54
|
case response
|
71
55
|
when 'y','yes'
|
72
56
|
new_title = File.dirname(name[:original_title]) + '/' + name[:title].gsub(/[\.|\_]/," ").gsub(/[\/|:]/,"-") + File.extname(name[:original_title])
|
@@ -86,17 +70,10 @@ module MovieManagerGem
|
|
86
70
|
# you'll have to run the command again to continue
|
87
71
|
end
|
88
72
|
end
|
89
|
-
|
90
|
-
# http://sequel.jeremyevans.net/rdoc/files/doc/cheat_sheet_rdoc.html#label-Update%2FDelete+rows
|
91
|
-
# be sure to bake in http://www.ruby-doc.org/core-2.1.2/File.html#method-c-rename
|
92
|
-
#File.rename(old,new)
|
93
|
-
#File.extname(file) gets extension
|
94
|
-
#File.dirname(file)
|
95
|
-
# change db record, change filename
|
96
73
|
end
|
97
74
|
|
98
75
|
def find_files_in(path) # works
|
99
|
-
#
|
76
|
+
# tried using ~/ as the default path. Returned too many unrelated videos.
|
100
77
|
Dir.chdir(path) do
|
101
78
|
enqueue_local_movies
|
102
79
|
add_all_movies_to_table
|
@@ -126,9 +103,23 @@ module MovieManagerGem
|
|
126
103
|
end
|
127
104
|
|
128
105
|
### List and Play Movies ###
|
106
|
+
def display_movie_info(title)
|
107
|
+
movie_list = @movie_genre_join.where(Sequel.ilike(:title, '%'+title+'%'), :available => 1).all # sqlite3 implementation
|
108
|
+
if movie_list.empty?
|
109
|
+
puts "Sorry, couldn't find '#{title}'"
|
110
|
+
else
|
111
|
+
puts "Title: #{movie_list[0][:title]}"
|
112
|
+
puts "Genre(s): #{movie_list.inject([]){|out, movie| out<<movie[:genre]}.join(", ")}"
|
113
|
+
puts "Rating: #{movie_list[0][:imdb_score]}/10"
|
114
|
+
puts "Length: #{movie_list[0][:length]} min."
|
115
|
+
puts "Summary:"
|
116
|
+
puts "#{movie_list[0][:summary]}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
129
120
|
def list_all_movies(min_score=-1) # works
|
130
|
-
movie_list = @movie_director_join.where({:available => 1}, (Sequel.expr(:
|
131
|
-
# movie_list = @movie_directories_join.order(:title).distinct(:movies__id,:title).where({:available => 1}, (Sequel.expr(:
|
121
|
+
movie_list = @movie_director_join.where({:available => 1}, (Sequel.expr(:imdb_score) >= min_score)).group(:movies__id).order(:title).all # sqlite3 impementation
|
122
|
+
# movie_list = @movie_directories_join.order(:title).distinct(:movies__id,:title).where({:available => 1}, (Sequel.expr(:imdb_score) >= min_score)).all? # postgres implementation
|
132
123
|
|
133
124
|
if movie_list.empty?
|
134
125
|
puts "Sorry, we don\'t have any movies with a score higher than #{min_score}"
|
@@ -158,8 +149,8 @@ module MovieManagerGem
|
|
158
149
|
@directors_dataset.select(:name).order(:name).all.each {|director| puts '- ' + director[:name]}
|
159
150
|
return
|
160
151
|
end
|
161
|
-
movie_list = @movie_director_join.where({:name => director_name}, {:available => 1}, (Sequel.expr(:
|
162
|
-
#movie_list = @movie_director_join.order(:title).distinct(:movies__id,:title).where({:name => director_name} & {:available => 1} & (Sequel.expr(:
|
152
|
+
movie_list = @movie_director_join.where({:name => director_name}, {:available => 1}, (Sequel.expr(:imdb_score) >= min_score)).group(:movies__id).order(:title).all # sqlite3 implementation
|
153
|
+
#movie_list = @movie_director_join.order(:title).distinct(:movies__id,:title).where({:name => director_name} & {:available => 1} & (Sequel.expr(:imdb_score) >= min_score)).all # postgres implementation
|
163
154
|
|
164
155
|
if movie_list.empty?
|
165
156
|
puts "Sorry, we don\'t have any movies directed by \'#{director_name}\'."
|
@@ -190,8 +181,8 @@ module MovieManagerGem
|
|
190
181
|
@actors_dataset.select(:name).order(:name).all.each {|actor| puts '- ' + actor[:name]}
|
191
182
|
return
|
192
183
|
end
|
193
|
-
movie_list = @movie_actor_join.where({:name => actor_name}, {:available => 1}, (Sequel.expr(:
|
194
|
-
# movie_list = @movie_actor_join.order(:title).distinct(:movies__id,:title).where({:name => actor_name}, {:available => 1}, (Sequel.expr(:
|
184
|
+
movie_list = @movie_actor_join.where({:name => actor_name}, {:available => 1}, (Sequel.expr(:imdb_score) >= min_score)).group(:movies__id).order(:title).all # sqlite3 implementation
|
185
|
+
# movie_list = @movie_actor_join.order(:title).distinct(:movies__id,:title).where({:name => actor_name}, {:available => 1}, (Sequel.expr(:imdb_score) >= min_score)).all # postgres implementation
|
195
186
|
|
196
187
|
if movie_list.empty?
|
197
188
|
puts "Sorry, we don\'t have any movies starring \'#{actor_name}\'."
|
@@ -202,22 +193,26 @@ module MovieManagerGem
|
|
202
193
|
end
|
203
194
|
|
204
195
|
def list_movies_by_genre(genre, min_score = -1) # works
|
205
|
-
movie_list = @movie_genre_join.where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1}
|
206
|
-
# movie_list = @movie_genre_join.order(:title).distinct(:movies__id,:title).where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1} & (Sequel.expr(:
|
196
|
+
movie_list = @movie_genre_join.where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1}).group(:movies__id).order(:title).all # sqlite3 implementation & (Sequel.expr(:imdb_score) >= min_score)
|
197
|
+
# movie_list = @movie_genre_join.order(:title).distinct(:movies__id,:title).where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1} & (Sequel.expr(:imdb_score) >= min_score)).all # postgres implementation
|
207
198
|
|
208
199
|
if movie_list.empty?
|
209
200
|
puts 'Sorry, we don\'t have that genre. Please enter one from the list:'
|
210
201
|
@genres_dataset.select(:genre).order(:genre).all.each {|genre| puts '- ' + genre[:genre]}
|
202
|
+
elsif movie_list.select {|movie| movie[:imdb_score] >= min_score}.empty?
|
203
|
+
puts "Sorry, couldn't find any movies with genre #{movie_list[0][:genre]} and a rating above #{min_score}"
|
211
204
|
else
|
212
205
|
search_genre = movie_list.first[:genre]
|
213
|
-
|
214
|
-
|
206
|
+
print "--- Movies with genre '#{search_genre}' "
|
207
|
+
print "rated above #{min_score} " if min_score != -1
|
208
|
+
puts "---"
|
209
|
+
movie_list.select {|movie| movie[:imdb_score] >= min_score}.each{ |movie| puts movie[:title]}
|
215
210
|
end
|
216
211
|
end
|
217
212
|
|
218
213
|
def play_unseen_genre(genre, min_score = -1) # works
|
219
|
-
movie_genre_list = @movie_genre_join.where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1} & (Sequel.expr(:
|
220
|
-
# movie_genre_list = @movie_genre_join.order(:title).distinct(:movies__id,:title).where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1} & (Sequel.expr(:
|
214
|
+
movie_genre_list = @movie_genre_join.where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1} & (Sequel.expr(:imdb_score) >= min_score)).group(:movies__id).all # sqlite3 implementation
|
215
|
+
# movie_genre_list = @movie_genre_join.order(:title).distinct(:movies__id,:title).where(Sequel.ilike(:genre, '%'+genre+'%') & {:available => 1} & (Sequel.expr(:imdb_score) >= min_score)).all # postgres implementation
|
221
216
|
if movie_genre_list.empty?
|
222
217
|
puts "Sorry, we don\'t have any movies with the genre #{genre}."
|
223
218
|
# this exception doesn't reveal if there are no movies of that genre above the minimum score
|
@@ -261,16 +256,15 @@ module MovieManagerGem
|
|
261
256
|
end
|
262
257
|
|
263
258
|
### Movie-handling fuctions ###
|
264
|
-
|
265
259
|
def enqueue_local_movies # works
|
266
260
|
movies_glob = Dir.glob('**/*.{mkv,MKV,avi,AVI,mp4,MP4,mpg,MPG,mov,MOV}').uniq
|
267
261
|
movies_glob.each {|movie| @local_movies_queue << [File.absolute_path(movie), normalize_title(movie), nil]}
|
268
|
-
#movies.select!{|movie| File.size(movie) > 600_000_000} # works
|
262
|
+
# movies.select!{|movie| File.size(movie) > 600_000_000} # works
|
269
263
|
end
|
270
264
|
|
271
265
|
def normalize_title(title) # works
|
272
|
-
# output should seperate path, suffix. Change
|
273
|
-
File.basename(title,'.*').gsub(/[\.|\_]/," ").gsub(/[\/|:]/,"-")
|
266
|
+
# output should seperate path, suffix. Change . and _ to spaces. Replace / and : with - to be unix-safe. remove anything in brackets or braces.
|
267
|
+
File.basename(title,'.*').gsub(/[\.|\_]/," ").gsub(/[\/|:]/,"-").gsub(/[\[|\{].*[\]|\}]/, "")
|
274
268
|
end
|
275
269
|
|
276
270
|
def update_directories_status # works
|
@@ -287,8 +281,8 @@ module MovieManagerGem
|
|
287
281
|
@movies_dataset.where(:title => movie_title).update(:watched => status)
|
288
282
|
end
|
289
283
|
|
290
|
-
def add_all_movies_to_table # works
|
291
|
-
|
284
|
+
def add_all_movies_to_table # works
|
285
|
+
# add func to auto-find/add new movies.
|
292
286
|
2.times do
|
293
287
|
# this code was supplied by Theo on SO
|
294
288
|
# http://stackoverflow.com/questions/6558828/thread-and-queue
|
@@ -300,7 +294,7 @@ module MovieManagerGem
|
|
300
294
|
movie_title = @movies_dataset.select(:title).where(:original_title => long_name).first[:title]
|
301
295
|
puts "#{movie_title} record already exists"
|
302
296
|
else
|
303
|
-
data =
|
297
|
+
data = get_imdb_movie_info(clean_name)
|
304
298
|
@processed_movies_queue << [long_name, clean_name, data]
|
305
299
|
add_movie(@processed_movies_queue.pop)
|
306
300
|
end
|
@@ -313,26 +307,26 @@ module MovieManagerGem
|
|
313
307
|
|
314
308
|
def add_movie((long_name, clean_name, data)) # works
|
315
309
|
if data
|
316
|
-
|
317
|
-
# Add Directories to directories_dataset
|
310
|
+
# Add Directory to directories_dataset
|
318
311
|
@directories_dataset.insert(:directory_path => File.dirname(long_name)) unless directories_record_exists?(File.dirname(long_name))
|
319
312
|
|
320
313
|
# Add Movie to movies_dataset
|
321
314
|
@movies_dataset.insert( :original_title => long_name,
|
322
|
-
:title => data.title,
|
323
|
-
:
|
324
|
-
:
|
315
|
+
:title => data.title[0..-8],
|
316
|
+
:imdb_score => data.rating,
|
317
|
+
:summary => data.plot_summary||'No summary available',
|
318
|
+
:length => data.length||-1,
|
325
319
|
:date_added => Time.new(),
|
326
320
|
:directory_id => @directories_dataset.select(:id).where(:directory_path => File.dirname(long_name)).first[:id])
|
327
321
|
|
328
|
-
movie_id = @movies_dataset.select(:id).where(:title => data.title).first[:id]
|
322
|
+
movie_id = @movies_dataset.select(:id).where(:title => data.title[0..-8]).first[:id]
|
329
323
|
|
330
324
|
# Add Actors to actors_dataset and movie_actor_dataset
|
331
|
-
data.
|
332
|
-
@actors_dataset.insert(:name => actor
|
325
|
+
data.cast_members.each do |actor|
|
326
|
+
@actors_dataset.insert(:name => actor) unless actors_record_exists?(actor) # used to be :name => actor.name. Make sure this works online!
|
333
327
|
@movie_actor_dataset.insert(:movie_id => movie_id,
|
334
|
-
:actor_id => @actors_dataset.select(:id).where(:name => actor
|
335
|
-
end if data.
|
328
|
+
:actor_id => @actors_dataset.select(:id).where(:name => actor).first[:id])
|
329
|
+
end if data.cast_members
|
336
330
|
|
337
331
|
# Add Genres to genres_dataset and movie_genre_dataset
|
338
332
|
data.genres.each do |genre|
|
@@ -342,13 +336,15 @@ module MovieManagerGem
|
|
342
336
|
end if data.genres
|
343
337
|
|
344
338
|
# Add Directors to directors_dataset and movie_director_dataset
|
345
|
-
data.
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
339
|
+
data.director.each do |director|
|
340
|
+
if director != "(more)" # compensates for a bug in imdb gem. Pull request submitted.
|
341
|
+
@directors_dataset.insert(:name => director) unless directors_record_exists?(director)
|
342
|
+
@movie_director_dataset.insert(:movie_id => movie_id,
|
343
|
+
:director_id => @directors_dataset.select(:id).where(:name => director).first[:id])
|
344
|
+
end
|
345
|
+
end if data.director
|
350
346
|
|
351
|
-
puts "#{data.title} added to table"
|
347
|
+
puts "#{data.title[0..-8]} added to table"
|
352
348
|
|
353
349
|
else
|
354
350
|
@movies_dataset.insert(:original_title => long_name, :title => clean_name, :date_added => Time.new())
|
@@ -356,28 +352,14 @@ module MovieManagerGem
|
|
356
352
|
end
|
357
353
|
end
|
358
354
|
|
359
|
-
def
|
360
|
-
|
361
|
-
|
362
|
-
output = RottenMovie.find(:title => clean_name, :expand_results => true, :limit => 1) # hits RT once to get general movie info
|
363
|
-
sleep 1
|
364
|
-
output = RottenMovie.find(:id => output.id) if output.class == PatchedOpenStruct # hits RT a second time with id# to get most detailed info :(
|
365
|
-
rescue # addresses the occasional crash that RT limits plus our volume of calls can bring on.
|
366
|
-
sleep 1
|
367
|
-
output = RottenMovie.find(:title => clean_name, :expand_results => true, :limit => 1) # hits RT once to get general movie info
|
368
|
-
sleep 1
|
369
|
-
output = RottenMovie.find(:id => output.id) if output.class == PatchedOpenStruct # hits RT a second time with id# to get most detailed info :(
|
370
|
-
end
|
371
|
-
return output if output.class == PatchedOpenStruct
|
355
|
+
def get_imdb_movie_info(clean_name) # works
|
356
|
+
i = Imdb::Search.new(clean_name)
|
357
|
+
return i.movies.first if i.movies.first.class == Imdb::Movie
|
372
358
|
return nil
|
373
|
-
|
374
|
-
# without internet (local offline testing)
|
375
|
-
# output = FakeMovie.new(clean_name)
|
376
|
-
# return output
|
377
359
|
end
|
378
360
|
|
379
361
|
|
380
|
-
|
362
|
+
### Exists? ###
|
381
363
|
def movies_record_exists?(original)
|
382
364
|
return false if @movies_dataset.select(:id).where(:original_title => original).all.length == 0
|
383
365
|
return true
|
@@ -403,19 +385,19 @@ module MovieManagerGem
|
|
403
385
|
return true
|
404
386
|
end
|
405
387
|
|
406
|
-
|
388
|
+
### Tables & DBs ###
|
407
389
|
def create_all_tables
|
408
|
-
create_directories_table
|
390
|
+
create_directories_table unless @@DB.table_exists?(:directories)
|
409
391
|
|
410
|
-
create_movies_table
|
392
|
+
create_movies_table unless @@DB.table_exists?(:movies)
|
411
393
|
|
412
|
-
create_genres_table
|
413
|
-
create_movie_genre_table
|
394
|
+
create_genres_table unless @@DB.table_exists?(:genres)
|
395
|
+
create_movie_genre_table unless @@DB.table_exists?(:movie_genre)
|
414
396
|
|
415
|
-
create_actors_table
|
416
|
-
create_movie_actor_table
|
397
|
+
create_actors_table unless @@DB.table_exists?(:actors)
|
398
|
+
create_movie_actor_table unless @@DB.table_exists?(:movie_actor)
|
417
399
|
|
418
|
-
create_directors_table
|
400
|
+
create_directors_table unless @@DB.table_exists?(:directors)
|
419
401
|
create_movie_director_table unless @@DB.table_exists?(:movie_director)
|
420
402
|
end
|
421
403
|
|
@@ -427,13 +409,14 @@ module MovieManagerGem
|
|
427
409
|
primary_key :id
|
428
410
|
String :original_title
|
429
411
|
String :title
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
412
|
+
Float :imdb_score, :default => -1 #1-100
|
413
|
+
Float :my_score, :default => -1 #1-100
|
414
|
+
Integer :correct_filename, :default => 0 #0/no, 1/yes
|
415
|
+
Integer :watched, :default => -1 #-1/unknown, 0/no, 1/yes
|
416
|
+
String :summary, {:text => true, :default => 'No summary available.'}
|
417
|
+
Integer :length, :default => -1
|
418
|
+
String :date_added
|
419
|
+
Integer :directory_id
|
437
420
|
end
|
438
421
|
end
|
439
422
|
end
|
@@ -539,90 +522,4 @@ module MovieManagerGem
|
|
539
522
|
end
|
540
523
|
end
|
541
524
|
end
|
542
|
-
|
543
|
-
class FakeMovie # works
|
544
|
-
# returns results when testing offline
|
545
|
-
attr_reader :title, :ratings, :critics_score, :audience_score, :my_score, :genres, :abridged_directors, :abridged_cast, :correct_filename, :watched, :name
|
546
|
-
def initialize(movie_title)
|
547
|
-
sleep 2 # you have to wait for RT, you have to wait for me!
|
548
|
-
|
549
|
-
@random = Random.new
|
550
|
-
@title = movie_title.upcase
|
551
|
-
@my_score = @random.rand(100)+1
|
552
|
-
@genres = %w(Comedy Documentary Drama Horror Western XXX).sample(@random.rand(3)+1)
|
553
|
-
@correct_filename = @random.rand(2)
|
554
|
-
@watched = @random.rand(2)
|
555
|
-
|
556
|
-
# cast & director names
|
557
|
-
@first = %w(Abe Bob Carl Dolf Earl)
|
558
|
-
@last = %w(Buler Crabtree Daniels McDonald)
|
559
|
-
|
560
|
-
# ratings
|
561
|
-
@critics_score = 101
|
562
|
-
@audience_score = 101
|
563
|
-
end
|
564
|
-
|
565
|
-
def ratings
|
566
|
-
return self
|
567
|
-
end
|
568
|
-
|
569
|
-
def abridged_cast
|
570
|
-
out = []
|
571
|
-
(@random.rand(5)+1).times do
|
572
|
-
out << {name: @first.sample + ' ' + @last.sample }
|
573
|
-
end
|
574
|
-
return out
|
575
|
-
end
|
576
|
-
|
577
|
-
def abridged_directors
|
578
|
-
out = []
|
579
|
-
(@random.rand(3)+1).times do
|
580
|
-
out << {name: 'Director ' + @last.sample }
|
581
|
-
end
|
582
|
-
return out
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
#### TO DO: ####
|
587
|
-
#
|
588
|
-
# some directories are listed as NULL. Find out why and fix it.
|
589
|
-
#
|
590
|
-
# X add directories DB
|
591
|
-
# X - add "directory present?" column to movies DB 0/1
|
592
|
-
# X - add "directory_present?" function to update dir status, runs on initialization. We assume no devices are being removed within a session.
|
593
|
-
# X - add "directory_present => 1" to all existing searches
|
594
|
-
#
|
595
|
-
# X update add_all_movies_to_table. Auto-find/add new movies.
|
596
|
-
#
|
597
|
-
# X if RT call fails, restart and continue.
|
598
|
-
#
|
599
|
-
# X add ARGV for command line input, woo! Look into Thor to help list commands
|
600
|
-
#
|
601
|
-
# X Let user specify directory root. use Dir.chdir(new_dir). Volume can be dragged and dropped in. request on init.
|
602
|
-
#
|
603
|
-
# X func search by actor/director
|
604
|
-
# X improve act/dir search with last name refinement
|
605
|
-
#
|
606
|
-
# Look into using Find instead of Dir.glob to allow the user to exclude some folders.
|
607
|
-
# http://ruby-doc.org/stdlib-1.9.3/libdoc/find/rdoc/Find.html
|
608
|
-
# can maybe also use reject on glob
|
609
|
-
# http://stackoverflow.com/questions/4505566/is-there-a-way-to-glob-a-directory-in-ruby-but-exclude-certain-directories
|
610
|
-
#
|
611
|
-
# X func is x the correct name? y/n
|
612
|
-
#
|
613
|
-
# swtich back to sqlite3 to make this a one click startup.
|
614
|
-
#
|
615
|
-
# X create a setup command. if db is empty, spcify a dir to look in, add movies, update dirs.
|
616
|
-
#
|
617
|
-
# X consider filtering actor/dir results if dir is unattached
|
618
|
-
# consider tracking play count rather than having it be binary
|
619
|
-
# consider making better use of the directory & origial movie name combo. feels redundant.
|
620
|
-
#
|
621
|
-
# X func update file names to reflect correct titles. Will need to be unix-safe
|
622
|
-
# http://superuser.com/questions/358855/what-characters-are-safe-in-cross-platform-file-names-for-linux-windows-and-os
|
623
|
-
#
|
624
|
-
# put on the web.
|
625
|
-
# Add filetypes.
|
626
|
-
# How to deal with file being renamed by user?
|
627
|
-
# Look at 'index on expressions'
|
628
|
-
end
|
525
|
+
end
|
data/movie-manager-gem.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["David Hamme"]
|
10
10
|
spec.email = ["dhamme@gmail.com"]
|
11
11
|
spec.summary = %q{A command line tool for organizing local movie files. }
|
12
|
-
spec.description = %q{DH Movie Manager finds local movie files, queries
|
12
|
+
spec.description = %q{DH Movie Manager finds local movie files, queries IMDB, and stores the data in a sqlite3 database that you can use to run commands. Search for specific actors, directors, and genres. Filter results by audience score. Update your filenames to reflect the correct title.
|
13
13
|
Feeling indecisive? use the 'play unseen [genre]' command to play a random movie that suits your mood.}
|
14
14
|
spec.homepage = "https://github.com/hammeiam/movie-manager-gem"
|
15
15
|
spec.license = "MIT"
|
@@ -22,8 +22,8 @@ Feeling indecisive? use the 'play unseen [genre]' command to play a random movie
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
28
|
-
spec.add_dependency
|
25
|
+
spec.add_dependency 'imdb', '~> 0.8.2'
|
26
|
+
spec.add_dependency 'sequel', '~> 4.13.0'
|
27
|
+
spec.add_dependency 'thread', '~> 0.1.4'
|
28
|
+
spec.add_dependency 'sqlite3', '~> 1.3.9'
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: movie-manager-gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Hamme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,66 +39,66 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: imdb
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.8.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.8.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sequel
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 4.13.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 4.13.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thread
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.1.4
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.1.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.3.9
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
description: "DH Movie Manager finds local movie files, queries
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
version: 1.3.9
|
97
|
+
description: "DH Movie Manager finds local movie files, queries IMDB, and stores the
|
98
|
+
data in a sqlite3 database that you can use to run commands. Search for specific
|
99
|
+
actors, directors, and genres. Filter results by audience score. Update your filenames
|
100
|
+
to reflect the correct title. \nFeeling indecisive? use the 'play unseen [genre]'
|
101
|
+
command to play a random movie that suits your mood."
|
102
102
|
email:
|
103
103
|
- dhamme@gmail.com
|
104
104
|
executables:
|
@@ -116,7 +116,6 @@ files:
|
|
116
116
|
- lib/movie-manager-gem.rb
|
117
117
|
- lib/movie-manager-gem/version.rb
|
118
118
|
- movie-manager-gem.gemspec
|
119
|
-
- movies.db
|
120
119
|
homepage: https://github.com/hammeiam/movie-manager-gem
|
121
120
|
licenses:
|
122
121
|
- MIT
|
data/movies.db
DELETED
Binary file
|