kastner-dvd_fingerprint 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ DVD Fingerprint
2
+ ===============
3
+
4
+ Generates a fingerprint for use with [disc ident](http://discident.com/ "Disc Ident"). Works by traversing a directory (from a DVD drive, or ripped) and creating a unique hash for that disc.
5
+
6
+ Usage
7
+ -----
8
+
9
+ require 'rubygems'
10
+ require 'kastner-dvd_fingerprint'
11
+
12
+ DVDFingerprint.fingerprint("/Volumes/DVD_VIDEO/")
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "dvd_fingerprint"
3
+ s.version = "0.0.2"
4
+ s.date = "2008-07-01"
5
+ s.summary = "Disc Fingerprint for http://discident.com/"
6
+ s.email = "kastner@gmail.com"
7
+ s.homepage = "http://github.com/kastner/dvd_fingerprint"
8
+ s.description = "Disc (DVD) fingerprinting for http://discident.com/."
9
+ s.has_rdoc = false
10
+ s.require_path = '.'
11
+ s.authors = ["Erik Kastner"]
12
+ s.files = ["dvd_fingerprint.rb", "dvd_fingerprint.gemspec", "README.mkdn"]
13
+ s.rdoc_options = ["--main", "README.mkdn"]
14
+ end
@@ -0,0 +1,61 @@
1
+ require 'digest/md5'
2
+
3
+ module DVDFingerprint
4
+ extend self
5
+
6
+ def generate_hash(string)
7
+ md5 = Digest::MD5.hexdigest(string)
8
+ md5.upcase.gsub(/(.{8})(.{4})(.{4})(.{4})(.*)/, '\1-\2-\3-\4-\5')
9
+ end
10
+
11
+ def get_paths(starting_path)
12
+ Dir["#{starting_path}/VIDEO_TS/**/*"].map { |f| [f.gsub(/#{starting_path}/,''), File.size(f)].join(":")}
13
+ end
14
+
15
+ def combine_files(paths)
16
+ paths.sort.join(":")
17
+ end
18
+
19
+ def fingerprint(path)
20
+ paths = get_paths(path)
21
+ string = combine_files(paths)
22
+ generate_hash(string)
23
+ end
24
+ end
25
+
26
+ if $0 == __FILE__
27
+ require 'rubygems'
28
+ require 'test/spec'
29
+
30
+ def test_string
31
+ ":/VIDEO_TS/VIDEO_TS.BUP:12288:/VIDEO_TS/VIDEO_TS.IFO:12288:/VIDEO_TS/VIDEO_TS.VOB:58052608:/VIDEO_TS/VTS_01_0.BUP:98304:/VIDEO_TS/VTS_01_0.IFO:98304:/VIDEO_TS/VTS_01_0.VOB:75163648:/VIDEO_TS/VTS_01_1.VOB:1073598464:/VIDEO_TS/VTS_01_2.VOB:1073448960:/VIDEO_TS/VTS_01_3.VOB:1073741824:/VIDEO_TS/VTS_01_4.VOB:1073647616:/VIDEO_TS/VTS_01_5.VOB:835813376"
32
+ end
33
+
34
+ def test_paths
35
+ [
36
+ "/VIDEO_TS/VIDEO_TS.BUP",
37
+ "/VIDEO_TS/VIDEO_TS.IFO",
38
+ "/VIDEO_TS/VIDEO_TS.VOB",
39
+ "/VIDEO_TS/VTS_01_0.BUP",
40
+ "/VIDEO_TS/VTS_01_0.IFO",
41
+ "/VIDEO_TS/VTS_01_0.VOB",
42
+ "/VIDEO_TS/VTS_01_1.VOB",
43
+ "/VIDEO_TS/VTS_01_2.VOB",
44
+ "/VIDEO_TS/VTS_01_3.VOB",
45
+ "/VIDEO_TS/VTS_01_4.VOB",
46
+ "/VIDEO_TS/VTS_01_5.VOB"
47
+ ]
48
+ end
49
+
50
+ describe "The Doors DVD - already traversed" do
51
+ it "should return the test hash" do
52
+ DVDFingerprint.generate_hash(test_string).should == "2075AB92-06CD-ED43-A753-2B75627BE844"
53
+ end
54
+
55
+ it "should calculate the test string given the directory structure" do
56
+ DVDFingerprint.combine_files(test_string).should == test_string
57
+ end
58
+ end
59
+ end
60
+
61
+ # puts DVDFingerprint.combine_files(DVDFingerprint.get_paths("/Volumes/DVD_VIDEO/"))
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kastner-dvd_fingerprint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Erik Kastner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-07-01 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Disc (DVD) fingerprinting for http://discident.com/.
17
+ email: kastner@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - dvd_fingerprint.rb
26
+ - dvd_fingerprint.gemspec
27
+ - README.mkdn
28
+ has_rdoc: false
29
+ homepage: http://github.com/kastner/dvd_fingerprint
30
+ post_install_message:
31
+ rdoc_options:
32
+ - --main
33
+ - README.mkdn
34
+ require_paths:
35
+ - .
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ requirements: []
49
+
50
+ rubyforge_project:
51
+ rubygems_version: 1.2.0
52
+ signing_key:
53
+ specification_version: 2
54
+ summary: Disc Fingerprint for http://discident.com/
55
+ test_files: []
56
+