-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/BlenderViking/NewPipeExtr…
…actor into play
- Loading branch information
Showing
9 changed files
with
435 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.schabi.newpipe.extractor.playlist; | ||
|
||
import org.schabi.newpipe.extractor.UrlIdHandler; | ||
import org.schabi.newpipe.extractor.exceptions.ExtractionException; | ||
import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; | ||
|
||
import java.io.IOException; | ||
|
||
public abstract class PlayListExtractor { | ||
|
||
private int serviceId; | ||
private String url; | ||
private UrlIdHandler urlIdHandler; | ||
private StreamInfoItemCollector previewInfoCollector; | ||
private int page = -1; | ||
|
||
public PlayListExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId) | ||
throws ExtractionException, IOException { | ||
this.url = url; | ||
this.page = page; | ||
this.serviceId = serviceId; | ||
this.urlIdHandler = urlIdHandler; | ||
previewInfoCollector = new StreamInfoItemCollector(urlIdHandler, serviceId); | ||
} | ||
|
||
public String getUrl() { return url; } | ||
public UrlIdHandler getUrlIdHandler() { return urlIdHandler; } | ||
public StreamInfoItemCollector getStreamPreviewInfoCollector() { | ||
return previewInfoCollector; | ||
} | ||
|
||
public abstract String getName() throws ParsingException; | ||
public abstract String getAvatarUrl() throws ParsingException; | ||
public abstract String getBannerUrl() throws ParsingException; | ||
public abstract StreamInfoItemCollector getStreams() throws ParsingException; | ||
public abstract boolean hasNextPage() throws ParsingException; | ||
public int getServiceId() { | ||
return serviceId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.schabi.newpipe.extractor.playlist; | ||
|
||
import org.schabi.newpipe.extractor.InfoItem; | ||
import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; | ||
|
||
import java.util.List; | ||
import java.util.Vector; | ||
|
||
public class PlayListInfo { | ||
|
||
public void addException(Exception e) { | ||
errors.add(e); | ||
} | ||
|
||
public static PlayListInfo getInfo(PlayListExtractor extractor) throws ParsingException { | ||
PlayListInfo info = new PlayListInfo(); | ||
|
||
info.playList_name = extractor.getName(); | ||
info.hasNextPage = extractor.hasNextPage(); | ||
|
||
try { | ||
info.avatar_url = extractor.getAvatarUrl(); | ||
} catch (Exception e) { | ||
info.errors.add(e); | ||
} | ||
try { | ||
info.banner_url = extractor.getBannerUrl(); | ||
} catch (Exception e) { | ||
info.errors.add(e); | ||
} | ||
try { | ||
StreamInfoItemCollector c = extractor.getStreams(); | ||
info.related_streams = c.getItemList(); | ||
info.errors.addAll(c.getErrors()); | ||
} catch(Exception e) { | ||
info.errors.add(e); | ||
} | ||
|
||
return info; | ||
} | ||
|
||
public int service_id = -1; | ||
public String playList_name = ""; | ||
public String avatar_url = ""; | ||
public String banner_url = ""; | ||
public List<InfoItem> related_streams = null; | ||
public boolean hasNextPage = false; | ||
|
||
public List<Throwable> errors = new Vector<>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.schabi.newpipe.extractor.playlist; | ||
|
||
import org.schabi.newpipe.extractor.InfoItem; | ||
|
||
public class PlayListInfoItem implements InfoItem { | ||
|
||
public int serviceId = -1; | ||
public String name = ""; | ||
public String thumbnailUrl = ""; | ||
public String webPageUrl = ""; | ||
|
||
public InfoType infoType() { | ||
return InfoType.PLAYLIST; | ||
} | ||
public String getTitle() { | ||
return name; | ||
} | ||
public String getLink() { | ||
return webPageUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.schabi.newpipe.extractor.playlist; | ||
|
||
import org.schabi.newpipe.extractor.InfoItemCollector; | ||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor; | ||
import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
|
||
public class PlayListInfoItemCollector extends InfoItemCollector { | ||
public PlayListInfoItemCollector(int serviceId) { | ||
super(serviceId); | ||
} | ||
|
||
public PlayListInfoItem extract(PlayListInfoItemExtractor extractor) throws ParsingException { | ||
final PlayListInfoItem resultItem = new PlayListInfoItem(); | ||
|
||
resultItem.name = extractor.getPlayListName(); | ||
resultItem.serviceId = getServiceId(); | ||
resultItem.webPageUrl = extractor.getWebPageUrl(); | ||
try { | ||
resultItem.thumbnailUrl = extractor.getThumbnailUrl(); | ||
} catch (Exception e) { | ||
addError(e); | ||
} | ||
return resultItem; | ||
} | ||
|
||
public void commit(PlayListInfoItemExtractor extractor) throws ParsingException { | ||
try { | ||
addItem(extract(extractor)); | ||
} catch (Exception e) { | ||
addError(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.schabi.newpipe.extractor.playlist; | ||
|
||
import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
|
||
public interface PlayListInfoItemExtractor { | ||
String getThumbnailUrl() throws ParsingException; | ||
String getPlayListName() throws ParsingException; | ||
String getWebPageUrl() throws ParsingException; | ||
} |
Oops, something went wrong.