Class: Giitaayan
- Inherits:
-
Lyrics
show all
- Defined in:
- lib/wiki_lyrics/lyrics_Giitaayan.rb
Constant Summary
collapse
- @@prefix =
"http://thaxi.hsc.usc.edu/rmim/giitaayan/cisb/"
- @@prefix_regexp =
/<a href=" *(#{@@prefix.gsub( "\\", "\\\\" ).gsub( ".", "\\." )}[^"]+.isb)">/
Instance Attribute Summary
Attributes inherited from Lyrics
#cleanup_lyrics
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Lyrics
build_google_feeling_lucky_url, #build_google_feeling_lucky_url, #build_lyrics_fetch_data, #build_song_add_url, #decrease_tabulation_level, #fetch_lyrics_page, #fetch_suggestions_page, #increase_tabulation_level, #initialize, #known_url?, #log, #log?, #logger=, #lyrics_direct_search, #lyrics_from_suggestions, #lyrics_from_url, #lyrics_full_search, #lyrics_page_valid?, #lyrics_test_data, #notify, #site_host, #site_name, #suggestions, #suggestions_page_valid?, suggestions_test_data, #suggestions_test_data, #verbose_log?
Constructor Details
This class inherits a constructor from Lyrics
Class Method Details
.build_song_add_url(request) ⇒ Object
56
57
58
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 56
def Giitaayan.build_song_add_url( request )
return "http://#{site_host()}/submit.asp"
end
|
.known_url?(url) ⇒ Boolean
52
53
54
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 52
def Giitaayan.known_url?( url )
return url.index( @@prefix ) == 0
end
|
.lyrics_test_data ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 43
def Giitaayan.lyrics_test_data()
return [
Request.new( "Abhijit, Kavita Subramaniam", ITRANS.to_devanagari( "a.ndherii raat me.n ham aur tum" ), "Juhi" ),
Request.new( "Poornima, Chorus", ITRANS.to_devanagari( "a aa ii u u uu meraa dil na to.Do" ), "Raajaa Baabu" ),
Request.new( "Sonu Nigam, Chorus", ITRANS.to_devanagari("gayaa gayaa dil jaane de" ), "Fizaa" ),
Request.new( "Lata, Hemant", ITRANS.to_devanagari( "ulajh gaye do nainaa, dekho" ), "Ek Saal" ),
]
end
|
.site_host ⇒ Object
35
36
37
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 35
def Giitaayan.site_host()
return "www.giitaayan.com"
end
|
.site_name ⇒ Object
39
40
41
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 39
def Giitaayan.site_name()
return "Giitaayan"
end
|
Instance Method Details
#build_suggestions_fetch_data(request) ⇒ Object
97
98
99
100
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 97
def build_suggestions_fetch_data( request )
title = CGI.escape( ITRANS.from_devanagari( request.title ) )
return FetchPageData.new( "http://#{site_host()}/search.asp?browse=stitle&s=#{title}" )
end
|
#parse_lyrics(response, page_body) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 60
def parse_lyrics( response, page_body )
custom_data = {}
["stitle", "film", "year", "starring", "singer", "music", "lyrics"].each() do |key|
if (md = /\\#{key}\{(.+)\}%/.match( page_body ))
custom_data[key] = md[1]
end
end
response.artist = custom_data["singer"]
response.album = custom_data["film"]
response.year = custom_data["year"]
custom_data["lyricist"] = custom_data["lyrics"] if ! Strings.empty?( custom_data["lyrics"] )
if ! Strings.empty?( custom_data["music"] ) || ! Strings.empty?( custom_data["lyrics"] )
custom_data["credits"] = "#{custom_data["music"]} #{custom_data["lyrics"]}".strip()
end
if ! Strings.empty?( custom_data["stitle"] )
custom_data["stitle"] = ITRANS.to_devanagari( custom_data["stitle"] )
response.title = custom_data["stitle"]
end
response.custom_data = custom_data
return if ! page_body.gsub!( /^.*\n#indian\s*\n%?/m, "" )
return if ! page_body.gsub!( /%?\s*\n#endindian.*$/m, "" )
page_body.gsub!( "\\threedots", "..." )
page_body.gsub!( "\\-", "-" )
page_body.gsub!( "\\:", ":" )
page_body.gsub!( /%[^\n]*/, "" )
response.lyrics = ITRANS.to_devanagari( page_body )
end
|
#parse_suggestions(request, page_body, page_url) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/wiki_lyrics/lyrics_Giitaayan.rb', line 102
def parse_suggestions( request, page_body, page_url )
page_body.tr_s!( " \n\r\t", " " )
suggestions = []
return suggestions if page_body.include?( "Sorry, no song found for your search!" )
return suggestions if ! page_body.sub!( /^.*<div align="center"><b>Lyrics<\/b><\/div> ?<\/td> ?<\/tr> ?<tr>/, "" )
return suggestions if ! page_body.sub!( /<form name="form1" method="get" action="search\.asp".*$/, "" )
page_body.gsub!( /<br> ?Page <b>1<\/b> ?<a href="search.asp\?PageNo=2&s=na&browse=stitle">.*$/, "" )
page_body.split( /<\/tr> ?<tr> ?/ ).each() do |sugg|
if (md1 = /^ ?<td>([^<]+) - <a/.match( sugg )) && (md2 = @@prefix_regexp.match( sugg ))
suggestions << Suggestion.new( request.artist, ITRANS.to_devanagari( md1[1] ), md2[1] )
end
end
return suggestions
end
|