@@ -10,7 +10,8 @@ def self.config
1010 {
1111 key : 'gray_scott_event' ,
1212 title : 'Gray Scott Events API' ,
13- category : :events
13+ category : :events ,
14+ user_agent : 'TeSS Gray Scott ingestor'
1415 }
1516 end
1617
@@ -33,12 +34,13 @@ def process_gray_scott(url)
3334 def process_calevent ( calevent , url )
3435 # puts "calevent: #{calevent.inspect}"
3536 gs_url = calevent . custom_properties . find { |key , _ | key . include? ( 'http' ) } &.last &.first &.strip &.gsub ( %r{^[/\s ]+|[/\s ]+$} , '' ) &.prepend ( 'https://' )
36- html = get_html_from_url ( get_redirected_url ( gs_url ) )
37+ html = get_html_from_url ( get_gray_scott_redirection ( gs_url ) )
3738
3839 event = OpenStruct . new
3940 event . title = calevent . summary . to_s
4041 event . url = gs_url
41- event . description = html . css ( '.paragraphStyle' ) . text . strip || calevent . description . to_s
42+ html_description = html . css ( '.paragraphStyle' ) . text . to_s . strip
43+ event . description = html_description . empty? ? calevent . description . to_s : html_description
4244
4345 event . end = calevent . dtend &.to_time &.utc
4446 unless calevent . dtstart . nil?
@@ -53,7 +55,7 @@ def process_calevent(calevent, url)
5355 @events << event
5456 end
5557
56- def get_redirected_url ( url )
58+ def get_gray_scott_redirection ( url )
5759 uri = URI . parse ( url )
5860 label = CGI . parse ( uri . query ) [ 'label' ] &.first
5961
@@ -63,6 +65,7 @@ def get_redirected_url(url)
6365
6466 dict = JSON . parse ( dict_match [ 1 ] )
6567 matched_value = dict [ label ]
68+ return url unless matched_value
6669
6770 "#{ uri . scheme } ://#{ uri . host } #{ uri . path . sub ( %r{/[^/]+$} , '' ) } /#{ matched_value } "
6871 end
0 commit comments