add addblock

This commit is contained in:
Christian Schabesberger 2016-09-12 00:51:03 +02:00
parent 6944f4a68a
commit a63128bd45
3 changed files with 37 additions and 3 deletions

View file

@ -0,0 +1,30 @@
package org.schabi.newpipe.extractor;
/**
* Created by Christian Schabesberger on 12.09.16.
*
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* FoundAdException.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 <http://www.gnu.org/licenses/>.
*/
public class FoundAdException extends ParsingException {
public FoundAdException(String message) {
super(message);
}
public FoundAdException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -62,7 +62,7 @@ public class StreamPreviewInfoCollector {
resultItem.title = extractor.getTitle(); resultItem.title = extractor.getTitle();
resultItem.stream_type = extractor.getStreamType(); resultItem.stream_type = extractor.getStreamType();
// optional iformation // optional information
try { try {
resultItem.duration = extractor.getDuration(); resultItem.duration = extractor.getDuration();
} catch (Exception e) { } catch (Exception e) {
@ -89,6 +89,8 @@ public class StreamPreviewInfoCollector {
addError(e); addError(e);
} }
itemList.add(resultItem); itemList.add(resultItem);
} catch(FoundAdException ae) {
System.out.println("AD_WARNING: " + ae.getMessage());
} catch (Exception e) { } catch (Exception e) {
addError(e); addError(e);
} }

View file

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.schabi.newpipe.extractor.FoundAdException;
import org.schabi.newpipe.extractor.Parser; import org.schabi.newpipe.extractor.Parser;
import org.schabi.newpipe.extractor.ParsingException; import org.schabi.newpipe.extractor.ParsingException;
import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.UrlIdHandler;
@ -56,8 +57,9 @@ public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
else if(url.contains("vnd.youtube")) else if(url.contains("vnd.youtube"))
{ {
id = Parser.matchGroup1("([\\-a-zA-Z0-9_]{11}).*", url); id = Parser.matchGroup1("([\\-a-zA-Z0-9_]{11}).*", url);
} } else if(url.contains("googleads")) {
else { throw new FoundAdException("Error found add: " + url);
} else {
id = Parser.matchGroup1("[?&]v=([\\-a-zA-Z0-9_]{11})", url); id = Parser.matchGroup1("[?&]v=([\\-a-zA-Z0-9_]{11})", url);
} }
} }