-
-
Notifications
You must be signed in to change notification settings - Fork 493
Add support for channel tabs #951
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
Changes from 26 commits
ed4559d
8b4b431
18e3758
78bbbd4
9a9fae9
667ab2a
57865e2
aed685e
53e772c
e6907ca
04c7e46
edaaaac
1253773
94523ad
a592c96
f3b064a
0a458d8
856584f
7ec6a44
f71fdac
73c182f
abf0473
8a3545c
7dba12b
f6d8652
2245de1
8d3bc2b
f7e3b71
ffd02a4
c156c40
d2c2aca
8446e20
9cebcf7
5b63a3e
76052de
8ecee87
8cd6439
c6ee2f3
97d7ee5
f306db0
e57d43f
750f158
e278a2d
c3651be
12ca6a2
294ffab
bad1238
6e0ffaf
308fc43
6b627f8
2ad496f
0c5fdac
6a38811
d47d0f9
417b797
0e28f2b
0583515
a3f6a7e
d868746
2adc2ca
e8fab3b
b1f8905
66d8038
6c5a225
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.schabi.newpipe.extractor.channel; | ||
|
||
import org.schabi.newpipe.extractor.InfoItem; | ||
import org.schabi.newpipe.extractor.ListExtractor; | ||
import org.schabi.newpipe.extractor.StreamingService; | ||
import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public abstract class ChannelTabExtractor extends ListExtractor<InfoItem> { | ||
|
||
public ChannelTabExtractor(final StreamingService service, | ||
final ListLinkHandler linkHandler) { | ||
super(service, linkHandler); | ||
} | ||
|
||
@Nonnull | ||
public String getTab() { | ||
Theta-Dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return getLinkHandler().getContentFilters().get(0); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getName() throws ParsingException { | ||
return getTab(); | ||
} | ||
} |
Theta-Dev marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.schabi.newpipe.extractor.channel; | ||
|
||
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.exceptions.ExtractionException; | ||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; | ||
import org.schabi.newpipe.extractor.utils.ExtractorHelper; | ||
|
||
import java.io.IOException; | ||
|
||
public class ChannelTabInfo extends ListInfo<InfoItem> { | ||
public ChannelTabInfo(final int serviceId, final ListLinkHandler linkHandler) { | ||
super(serviceId, linkHandler, linkHandler.getContentFilters().get(0)); | ||
} | ||
|
||
public static ChannelTabInfo getInfo(final StreamingService service, | ||
final ListLinkHandler linkHandler) | ||
throws ExtractionException, IOException { | ||
final ChannelTabExtractor extractor = service.getChannelTabExtractor(linkHandler); | ||
extractor.fetchPage(); | ||
return getInfo(extractor); | ||
} | ||
|
||
public static ChannelTabInfo getInfo(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( | ||
final StreamingService service, final ListLinkHandler linkHandler, final Page page) | ||
throws ExtractionException, IOException { | ||
return service.getChannelTabExtractor(linkHandler).getPage(page); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.schabi.newpipe.extractor.linkhandler; | ||
|
||
public final class ChannelTabs { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are using strings for channel tabs names, however this open the door to several I think a dedicated base (abstract) structure should be created for tabs, and this structure should be implemented in services, because different services may have different tab names for the same type of contents. This structure should allow getting its name, what it contains (streams, playlists, channels, [...] or multiple type of contents) and maybe the service ID and/or more. But as you rely on content and sort filters, which are currently strings, this is out of the scope of this PR. These filters should be refactored too (made in #904). |
||
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() { | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific reason why this is not an enum? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used an enum in the initial version, but decided to use the existing LinkHandlers which take strings for content filtering. The search function works the same. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you use an enum and call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is an option. But I dont see an advantage in that. We wont get the type safety of an enum and it would make the code longer. There arent any enums used for search filters, either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, sure, but we can check that they're valid by iterating over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmmh, I agree with @FireMasterK that |
Uh oh!
There was an error while loading. Please reload this page.