-
-
Notifications
You must be signed in to change notification settings - Fork 543
ADD basic playlist support + youtube playlist support #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the spacing.