Fix errors being logged due to invalid requests. (#303)

This commit is contained in:
Kavin 2022-07-04 07:09:29 +01:00 committed by GitHub
parent 606cbf5ca6
commit c812ace4f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -274,6 +274,9 @@ public class ResponseHelper {
public static byte[] channelPageResponse(String channelId, String prevpageStr) public static byte[] channelPageResponse(String channelId, String prevpageStr)
throws IOException, ExtractionException { throws IOException, ExtractionException {
if (StringUtils.isEmpty(prevpageStr))
return mapper.writeValueAsBytes(new InvalidRequestResponse());
Page prevpage = mapper.readValue(prevpageStr, Page.class); Page prevpage = mapper.readValue(prevpageStr, Page.class);
InfoItemsPage<StreamInfoItem> info = ChannelInfo.getMoreItems(YOUTUBE_SERVICE, InfoItemsPage<StreamInfoItem> info = ChannelInfo.getMoreItems(YOUTUBE_SERVICE,
@ -388,6 +391,9 @@ public class ResponseHelper {
public static byte[] playlistPageResponse(String playlistId, String prevpageStr) public static byte[] playlistPageResponse(String playlistId, String prevpageStr)
throws IOException, ExtractionException { throws IOException, ExtractionException {
if (StringUtils.isEmpty(prevpageStr))
return mapper.writeValueAsBytes(new InvalidRequestResponse());
Page prevpage = mapper.readValue(prevpageStr, Page.class); Page prevpage = mapper.readValue(prevpageStr, Page.class);
InfoItemsPage<StreamInfoItem> info = PlaylistInfo.getMoreItems(YOUTUBE_SERVICE, InfoItemsPage<StreamInfoItem> info = PlaylistInfo.getMoreItems(YOUTUBE_SERVICE,
@ -552,6 +558,9 @@ public class ResponseHelper {
public static byte[] searchPageResponse(String q, String filter, String prevpageStr) public static byte[] searchPageResponse(String q, String filter, String prevpageStr)
throws IOException, ExtractionException { throws IOException, ExtractionException {
if (StringUtils.isEmpty(prevpageStr))
return mapper.writeValueAsBytes(new InvalidRequestResponse());
Page prevpage = mapper.readValue(prevpageStr, Page.class); Page prevpage = mapper.readValue(prevpageStr, Page.class);
InfoItemsPage<InfoItem> pages = SearchInfo.getMoreItems(YOUTUBE_SERVICE, InfoItemsPage<InfoItem> pages = SearchInfo.getMoreItems(YOUTUBE_SERVICE,
@ -622,6 +631,9 @@ public class ResponseHelper {
public static byte[] commentsPageResponse(String videoId, String prevpageStr) throws Exception { public static byte[] commentsPageResponse(String videoId, String prevpageStr) throws Exception {
if (StringUtils.isEmpty(prevpageStr))
return mapper.writeValueAsBytes(new InvalidRequestResponse());
Page prevpage = mapper.readValue(prevpageStr, Page.class); Page prevpage = mapper.readValue(prevpageStr, Page.class);
InfoItemsPage<CommentsInfoItem> info = CommentsInfo.getMoreItems(YOUTUBE_SERVICE, "https://www.youtube.com/watch?v=" + videoId, prevpage); InfoItemsPage<CommentsInfoItem> info = CommentsInfo.getMoreItems(YOUTUBE_SERVICE, "https://www.youtube.com/watch?v=" + videoId, prevpage);