-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1082 from AudricV/channel-tabs-and-tags-support
Add support for channel tabs and channel tags
- Loading branch information
Showing
182 changed files
with
16,312 additions
and
4,285 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
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
25 changes: 25 additions & 0 deletions
25
extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.java
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,25 @@ | ||
package org.schabi.newpipe.extractor.channel.tabs; | ||
|
||
import org.schabi.newpipe.extractor.InfoItem; | ||
import org.schabi.newpipe.extractor.ListExtractor; | ||
import org.schabi.newpipe.extractor.StreamingService; | ||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* A {@link ListExtractor} of {@link InfoItem}s for tabs of channels. | ||
*/ | ||
public abstract class ChannelTabExtractor extends ListExtractor<InfoItem> { | ||
|
||
protected ChannelTabExtractor(@Nonnull final StreamingService service, | ||
@Nonnull final ListLinkHandler linkHandler) { | ||
super(service, linkHandler); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getName() { | ||
return getLinkHandler().getContentFilters().get(0); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabInfo.java
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,70 @@ | ||
package org.schabi.newpipe.extractor.channel.tabs; | ||
|
||
import org.schabi.newpipe.extractor.InfoItem; | ||
import org.schabi.newpipe.extractor.ListExtractor; | ||
import org.schabi.newpipe.extractor.ListInfo; | ||
import org.schabi.newpipe.extractor.Page; | ||
import org.schabi.newpipe.extractor.StreamingService; | ||
import org.schabi.newpipe.extractor.channel.ChannelInfo; | ||
import org.schabi.newpipe.extractor.exceptions.ExtractionException; | ||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; | ||
import org.schabi.newpipe.extractor.utils.ExtractorHelper; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.io.IOException; | ||
|
||
public class ChannelTabInfo extends ListInfo<InfoItem> { | ||
|
||
public ChannelTabInfo(final int serviceId, | ||
@Nonnull final ListLinkHandler linkHandler) { | ||
super(serviceId, linkHandler, linkHandler.getContentFilters().get(0)); | ||
} | ||
|
||
/** | ||
* Get a {@link ChannelTabInfo} instance from the given service and tab handler. | ||
* | ||
* @param service streaming service | ||
* @param linkHandler Channel tab handler (from {@link ChannelInfo}) | ||
* @return the extracted {@link ChannelTabInfo} | ||
*/ | ||
@Nonnull | ||
public static ChannelTabInfo getInfo(@Nonnull final StreamingService service, | ||
@Nonnull final ListLinkHandler linkHandler) | ||
throws ExtractionException, IOException { | ||
final ChannelTabExtractor extractor = service.getChannelTabExtractor(linkHandler); | ||
extractor.fetchPage(); | ||
return getInfo(extractor); | ||
} | ||
|
||
/** | ||
* Get a {@link ChannelTabInfo} instance from a {@link ChannelTabExtractor}. | ||
* | ||
* @param extractor an extractor where {@code fetchPage()} was already got called on | ||
* @return the extracted {@link ChannelTabInfo} | ||
*/ | ||
@Nonnull | ||
public static ChannelTabInfo getInfo(@Nonnull final ChannelTabExtractor extractor) { | ||
final ChannelTabInfo info = | ||
new ChannelTabInfo(extractor.getServiceId(), extractor.getLinkHandler()); | ||
|
||
try { | ||
info.setOriginalUrl(extractor.getOriginalUrl()); | ||
} catch (final Exception e) { | ||
info.addError(e); | ||
} | ||
|
||
final ListExtractor.InfoItemsPage<InfoItem> page | ||
= ExtractorHelper.getItemsPageOrLogError(info, extractor); | ||
info.setRelatedItems(page.getItems()); | ||
info.setNextPage(page.getNextPage()); | ||
|
||
return info; | ||
} | ||
|
||
public static ListExtractor.InfoItemsPage<InfoItem> getMoreItems( | ||
@Nonnull final StreamingService service, | ||
@Nonnull final ListLinkHandler linkHandler, | ||
@Nonnull final Page page) throws ExtractionException, IOException { | ||
return service.getChannelTabExtractor(linkHandler).getPage(page); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabs.java
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,17 @@ | ||
package org.schabi.newpipe.extractor.channel.tabs; | ||
|
||
/** | ||
* Constants of channel tabs supported by the extractor. | ||
*/ | ||
public final class ChannelTabs { | ||
public static final String VIDEOS = "videos"; | ||
public static final String TRACKS = "tracks"; | ||
public static final String SHORTS = "shorts"; | ||
public static final String LIVESTREAMS = "livestreams"; | ||
public static final String CHANNELS = "channels"; | ||
public static final String PLAYLISTS = "playlists"; | ||
public static final String ALBUMS = "albums"; | ||
|
||
private ChannelTabs() { | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/UnsupportedTabException.java
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,7 @@ | ||
package org.schabi.newpipe.extractor.exceptions; | ||
|
||
public final class UnsupportedTabException extends UnsupportedOperationException { | ||
public UnsupportedTabException(final String unsupportedTab) { | ||
super("Unsupported tab " + unsupportedTab); | ||
} | ||
} |
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
Oops, something went wrong.