kopia lustrzana https://github.com/TeamNewPipe/NewPipeExtractor
				
				
				
			Added description parsing for channel info.
							rodzic
							
								
									28d12cd90c
								
							
						
					
					
						commit
						e0f1b5cd79
					
				|  | @ -99,4 +99,9 @@ public class SoundcloudUserExtractor extends UserExtractor { | |||
| 
 | ||||
|         return new NextItemsResult(collector.getItemList(), nextStreamsUrl); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String getDescription() throws ParsingException { | ||||
|         return user.getString("description"); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -119,6 +119,15 @@ public class YoutubeUserExtractor extends UserExtractor { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String getDescription() throws ParsingException { | ||||
|         try { | ||||
|             return doc.select("meta[name=\"description\"]").first().attr("content"); | ||||
|         } catch(Exception e) { | ||||
|             throw new ParsingException("Could not get channel name", e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String getFeedUrl() throws ParsingException { | ||||
|         try { | ||||
|  |  | |||
|  | @ -45,5 +45,6 @@ public abstract class UserExtractor extends ListExtractor { | |||
|     public abstract String getBannerUrl() throws ParsingException; | ||||
|     public abstract String getFeedUrl() throws ParsingException; | ||||
|     public abstract long getSubscriberCount() throws ParsingException; | ||||
|     public abstract String getDescription() throws ParsingException; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -90,6 +90,11 @@ public class UserInfo extends ListInfo { | |||
|         } catch (Exception e) { | ||||
|             info.errors.add(e); | ||||
|         } | ||||
|         try { | ||||
|             info.description = extractor.getDescription(); | ||||
|         } catch (Exception e) { | ||||
|             info.errors.add(e); | ||||
|         } | ||||
| 
 | ||||
|         // Lists can be null if a exception was thrown during extraction
 | ||||
|         if (info.related_streams == null) info.related_streams = new ArrayList<>(); | ||||
|  | @ -103,4 +108,5 @@ public class UserInfo extends ListInfo { | |||
|     public String banner_url; | ||||
|     public String feed_url; | ||||
|     public long subscriber_count = -1; | ||||
|     public String description = ""; | ||||
| } | ||||
|  |  | |||
|  | @ -56,6 +56,11 @@ public class YoutubeUserExtractorTest  { | |||
|         assertEquals(extractor.getUserName(), "Gronkh"); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void testGetDescription() throws Exception { | ||||
|         assertEquals(extractor.getDescription(), "★ ★ ★ KLICK MICH HART, DU SAU! :D ★ ★ ★ Zart im Schmelz und süffig im Abgang. Ungebremster Spieltrieb seit 1896. Tägliche Folgen nonstop seit dem 01.04.2010!..."); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void testGetAvatarUrl() throws Exception { | ||||
|         assertTrue(extractor.getAvatarUrl(), extractor.getAvatarUrl().contains("yt3")); | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 John Zhen M
						John Zhen M