gemafind 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gemafind.rb +64 -0
- metadata +45 -0
data/lib/gemafind.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "nokogiri"
|
3
|
+
|
4
|
+
module GEMA
|
5
|
+
|
6
|
+
def GEMA.clean_str(str)
|
7
|
+
str.force_encoding("ISO-8859-1")
|
8
|
+
str.gsub(/[\r\n\t]/,"").gsub(/ +/," ").sub(/^ /,"").sub(/ $/,"")
|
9
|
+
end
|
10
|
+
|
11
|
+
def GEMA.query_single(query,key="mainPerformer",kind="beginsWith")
|
12
|
+
|
13
|
+
command='curl -s -S --data "searchFor='+key+'&searchKind='+kind+'&searchText='+query+'®isteredUser=false" http://mgonline.gema.de/soundcarrier/searchArea.do'
|
14
|
+
|
15
|
+
html=`#{command}`
|
16
|
+
|
17
|
+
doc=Nokogiri::HTML(html)
|
18
|
+
|
19
|
+
|
20
|
+
message=clean_str(doc.css("#resultInfo").text)
|
21
|
+
num_hits=0
|
22
|
+
num_hits=message.split(" ").first.to_i if message.match("Treffer")
|
23
|
+
|
24
|
+
rows=doc.css(".rowValue")
|
25
|
+
row_data=[]
|
26
|
+
ri=0
|
27
|
+
|
28
|
+
rows.each do |row|
|
29
|
+
row_data[ri]=[]
|
30
|
+
cells=row.css("td")
|
31
|
+
cells.each do |cell|
|
32
|
+
cell_data=clean_str(cell.text)
|
33
|
+
row_data[ri].push(cell_data) unless cell_data=="Zusatzinformationen"
|
34
|
+
end
|
35
|
+
ri+=1
|
36
|
+
end
|
37
|
+
|
38
|
+
result={
|
39
|
+
message:message,
|
40
|
+
num_hits:num_hits,
|
41
|
+
rows:row_data
|
42
|
+
}
|
43
|
+
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
def GEMA.query_all(query)
|
48
|
+
|
49
|
+
keys=[
|
50
|
+
"mainPerformer",
|
51
|
+
"nameReported"
|
52
|
+
]
|
53
|
+
|
54
|
+
result={}
|
55
|
+
|
56
|
+
keys.each do |k|
|
57
|
+
result[k]=query_single(query,k)
|
58
|
+
end
|
59
|
+
|
60
|
+
result
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemafind
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lukas F. Hartmann
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-12 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email: lukas@mnt.mn
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/gemafind.rb
|
21
|
+
homepage: https://github.com/mntmn/gemafind
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project: nowarning
|
41
|
+
rubygems_version: 1.8.10
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Search for artists in the German GEMA database (ILTIS)
|
45
|
+
test_files: []
|