File tree 1 file changed +19
-1
lines changed 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,24 @@ def uris
44
44
45
45
private
46
46
47
+ def find_programs ( obj )
48
+ case obj
49
+ when Array
50
+ obj . each do |elm |
51
+ result = find_programs ( elm )
52
+ return result unless result . nil?
53
+ end
54
+ when Hash
55
+ return obj if obj . key? ( 'programs' )
56
+
57
+ obj . each do |_ , value |
58
+ result = find_programs ( value )
59
+ return result unless result . nil?
60
+ end
61
+ end
62
+ nil
63
+ end
64
+
47
65
def encode ( component )
48
66
# Ruby dropped URI.encode, and CGI.escape converts spaces to `+` instead of `%20`
49
67
URI . encode_www_form_component ( component ) . gsub ( '+' , '%20' )
@@ -54,7 +72,7 @@ def directory_index
54
72
script = page . css ( 'script' ) . max_by do |node |
55
73
node . to_s . length
56
74
end . inner_text . match ( /self\. __next_f\. push\( \[ 1,(.*)\] / ) [ 1 ]
57
- programs = JSON . parse ( JSON . parse ( script ) [ 2 ..] ) [ 3 ] [ 'children' ] [ 1 ] [ 3 ] [ 'programs' ]
75
+ programs = find_programs ( JSON . parse ( JSON . parse ( script ) [ 2 ..] ) ) [ 'programs' ]
58
76
programs . map do |program |
59
77
{
60
78
id : program [ 'programId' ] ,
You can’t perform that action at this time.
0 commit comments