Class: Giitaayan
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
57
58
59
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 57
def Giitaayan.build_song_add_url( request )
return "http://#{site_host()}/submit.asp"
end
|
.known_url?(url) ⇒ Boolean
53
54
55
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 53
def Giitaayan.known_url?( url )
return url.index( @@prefix ) == 0
end
|
.lyrics_test_data ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 44
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
36
37
38
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 36
def Giitaayan.site_host()
return "www.giitaayan.com"
end
|
.site_name ⇒ Object
40
41
42
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 40
def Giitaayan.site_name()
return "Giitaayan"
end
|
Instance Method Details
#build_suggestions_fetch_data(request) ⇒ Object
98
99
100
101
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 98
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
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
96
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 61
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/lyrics/lyrics_Giitaayan.rb', line 103
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
|