mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	fixed another parsing but related to livestreams
This commit is contained in:
		| @@ -216,7 +216,14 @@ public class YoutubeSearchEngine extends SearchEngine { | |||||||
|                     return YoutubeParsingHelper.parseDurationString( |                     return YoutubeParsingHelper.parseDurationString( | ||||||
|                             item.select("span[class=\"video-time\"]").first().text()); |                             item.select("span[class=\"video-time\"]").first().text()); | ||||||
|                 } catch(Exception e) { |                 } catch(Exception e) { | ||||||
|                     throw new ParsingException("Could not get Duration", e); |                     if(isLiveStream(item)) { | ||||||
|  |                         // -1 for no duration | ||||||
|  |                         return -1; | ||||||
|  |                     } else { | ||||||
|  |                         throw new ParsingException("Could not get Duration", e); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -245,9 +252,21 @@ public class YoutubeSearchEngine extends SearchEngine { | |||||||
|             @Override |             @Override | ||||||
|             public long getViewCount() throws ParsingException { |             public long getViewCount() throws ParsingException { | ||||||
|                 String output; |                 String output; | ||||||
|                 String input = item.select("div[class=\"yt-lockup-meta\"]").first() |                 String input; | ||||||
|                         .select("li").get(1) |                 try { | ||||||
|                         .text(); |                     input = item.select("div[class=\"yt-lockup-meta\"]").first() | ||||||
|  |                             .select("li").get(1) | ||||||
|  |                             .text(); | ||||||
|  |                 } catch (IndexOutOfBoundsException e) { | ||||||
|  |                     if(isLiveStream(item)) { | ||||||
|  |                         // -1 for no view count | ||||||
|  |                         return -1; | ||||||
|  |                     } else { | ||||||
|  |                         throw new ParsingException( | ||||||
|  |                                 "Could not parse yt-lockup-meta although available", e); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 output = Parser.matchGroup1("([0-9,\\. ]*)", input) |                 output = Parser.matchGroup1("([0-9,\\. ]*)", input) | ||||||
|                         .replace(" ", "") |                         .replace(" ", "") | ||||||
|                         .replace(".", "") |                         .replace(".", "") | ||||||
| @@ -283,6 +302,11 @@ public class YoutubeSearchEngine extends SearchEngine { | |||||||
|                     throw new ParsingException("Could not get thumbnail url", e); |                     throw new ParsingException("Could not get thumbnail url", e); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             private boolean isLiveStream(Element item) { | ||||||
|  |                 Element bla = item.select("span[class*=\"yt-badge-live\"]").first(); | ||||||
|  |                 return bla != null; | ||||||
|  |             } | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Christian Schabesberger
					Christian Schabesberger