package org.schabi.newpipe.extractor.services.youtube.linkHandler; /* * Created by Christian Schabesberger on 12.08.17. * * Copyright (C) Christian Schabesberger 2018 * YoutubeTrendingLinkHandlerFactory.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NewPipe is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NewPipe. If not, see . */ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isInvidiousURL; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isYoutubeURL; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.utils.Utils; import java.net.MalformedURLException; import java.net.URL; import java.util.List; public class YoutubeTrendingLinkHandlerFactory extends ListLinkHandlerFactory { public String getUrl(final String id, final List contentFilters, final String sortFilter) { return "https://www.youtube.com/feed/trending"; } @Override public String getId(final String url) { return "Trending"; } @Override public boolean onAcceptUrl(final String url) { final URL urlObj; try { urlObj = Utils.stringToURL(url); } catch (final MalformedURLException e) { return false; } final String urlPath = urlObj.getPath(); return Utils.isHTTP(urlObj) && (isYoutubeURL(urlObj) || isInvidiousURL(urlObj)) && urlPath.equals("/feed/trending"); } }