@@ -126,22 +126,11 @@ public String getTextualUploadDate() throws ParsingException {
126126 } catch (Exception ignored ) {}
127127
128128 try {
129- JsonArray contents = initialData .getObject ("contents" ).getObject ("twoColumnWatchNextResults" ).getObject ("results" )
130- .getObject ("results" ).getArray ("contents" );
131- for (Object c : contents ) {
132- String unformattedDate = "" ;
133- try {
134- JsonObject o = (JsonObject ) c ;
135- unformattedDate = o .getObject ("videoPrimaryInfoRenderer" ).getObject ("dateText" ).getString ("simpleText" );
136-
137- } catch (Exception ignored ) {/* we got the wrong element form the array */ }
138- // TODO this parses English formatted dates only, we need a better approach to parse teh textual date
139- Date d = new SimpleDateFormat ("dd MMM yyy" ).parse (unformattedDate );
140- return new SimpleDateFormat ("yyyy-MM-dd" ).format (d );
141- }
142- } catch (Exception e ) {
143- throw new ParsingException ("Could not get upload date" , e );
144- }
129+ // TODO this parses English formatted dates only, we need a better approach to parse the textual date
130+ Date d = new SimpleDateFormat ("dd MMM yyy" ).parse (getVideoPrimaryInfoRenderer ()
131+ .getObject ("dateText" ).getString ("simpleText" ));
132+ return new SimpleDateFormat ("yyyy-MM-dd" ).format (d );
133+ } catch (Exception ignored ) {}
145134 throw new ParsingException ("Could not get upload date" );
146135 }
147136
@@ -351,7 +340,7 @@ public String getUploaderName() throws ParsingException {
351340 public String getUploaderAvatarUrl () throws ParsingException {
352341 assertPageFetched ();
353342
354- String uploaderAvatarUrl ;
343+ String uploaderAvatarUrl = null ;
355344 try {
356345 uploaderAvatarUrl = initialData .getObject ("contents" ).getObject ("twoColumnWatchNextResults" ).getObject ("secondaryResults" )
357346 .getObject ("secondaryResults" ).getArray ("results" ).getObject (0 ).getObject ("compactAutoplayRenderer" )
@@ -363,13 +352,9 @@ public String getUploaderAvatarUrl() throws ParsingException {
363352 } catch (Exception ignored ) {}
364353
365354 try {
366- uploaderAvatarUrl = initialData .getObject ("contents" ).getObject ("twoColumnWatchNextResults" ).getObject ("results" )
367- .getObject ("results" ).getArray ("contents" ).getObject (1 ).getObject ("videoSecondaryInfoRenderer" )
368- .getObject ("owner" ).getObject ("videoOwnerRenderer" ).getObject ("thumbnail" ).getArray ("thumbnails" )
369- .getObject (0 ).getString ("url" );
370- } catch (Exception e ) {
371- throw new ParsingException ("Could not get uploader avatar url" , e );
372- }
355+ uploaderAvatarUrl = getVideoSecondaryInfoRenderer ().getObject ("owner" ).getObject ("videoOwnerRenderer" )
356+ .getObject ("thumbnail" ).getArray ("thumbnails" ).getObject (0 ).getString ("url" );
357+ } catch (Exception ignored ) {}
373358
374359 if (uploaderAvatarUrl == null ) {
375360 throw new ParsingException ("Could not get uploader avatar url" );
0 commit comments