Skip to content

Commit 6ab3dc8

Browse files
committed
Merge branch 'master' of https://github.com/BlenderViking/NewPipeExtractor into play
2 parents 8ff28a6 + 281d23d commit 6ab3dc8

9 files changed

Lines changed: 435 additions & 0 deletions

StreamingService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
44
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
5+
import org.schabi.newpipe.extractor.playlist.PlayListExtractor;
56
import org.schabi.newpipe.extractor.search.SearchEngine;
67
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
78

@@ -52,8 +53,11 @@ public abstract StreamExtractor getExtractorInstance(String url)
5253
public abstract SearchEngine getSearchEngineInstance();
5354
public abstract UrlIdHandler getStreamUrlIdHandlerInstance();
5455
public abstract UrlIdHandler getChannelUrlIdHandlerInstance();
56+
public abstract UrlIdHandler getPlayListUrlIdHandlerInstance();
5557
public abstract ChannelExtractor getChannelExtractorInstance(String url, int page)
5658
throws ExtractionException, IOException;
59+
public abstract PlayListExtractor getPlayListExtractorInstance(String url, int page)
60+
throws ExtractionException, IOException;
5761
public abstract SuggestionExtractor getSuggestionExtractorInstance();
5862

5963
public final int getServiceId() {
@@ -66,11 +70,14 @@ public final int getServiceId() {
6670
public final LinkType getLinkTypeByUrl(String url) {
6771
UrlIdHandler sH = getStreamUrlIdHandlerInstance();
6872
UrlIdHandler cH = getChannelUrlIdHandlerInstance();
73+
UrlIdHandler pH = getPlayListUrlIdHandlerInstance();
6974

7075
if(sH.acceptUrl(url)) {
7176
return LinkType.STREAM;
7277
} else if(cH.acceptUrl(url)) {
7378
return LinkType.CHANNEL;
79+
} else if (pH.acceptUrl(url)) {
80+
return LinkType.PLAYLIST;
7481
} else {
7582
return LinkType.NONE;
7683
}

playlist/PlayListExtractor.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.schabi.newpipe.extractor.playlist;
2+
3+
import org.schabi.newpipe.extractor.UrlIdHandler;
4+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
5+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
6+
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector;
7+
8+
import java.io.IOException;
9+
10+
public abstract class PlayListExtractor {
11+
12+
private int serviceId;
13+
private String url;
14+
private UrlIdHandler urlIdHandler;
15+
private StreamInfoItemCollector previewInfoCollector;
16+
private int page = -1;
17+
18+
public PlayListExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId)
19+
throws ExtractionException, IOException {
20+
this.url = url;
21+
this.page = page;
22+
this.serviceId = serviceId;
23+
this.urlIdHandler = urlIdHandler;
24+
previewInfoCollector = new StreamInfoItemCollector(urlIdHandler, serviceId);
25+
}
26+
27+
public String getUrl() { return url; }
28+
public UrlIdHandler getUrlIdHandler() { return urlIdHandler; }
29+
public StreamInfoItemCollector getStreamPreviewInfoCollector() {
30+
return previewInfoCollector;
31+
}
32+
33+
public abstract String getName() throws ParsingException;
34+
public abstract String getAvatarUrl() throws ParsingException;
35+
public abstract String getBannerUrl() throws ParsingException;
36+
public abstract StreamInfoItemCollector getStreams() throws ParsingException;
37+
public abstract boolean hasNextPage() throws ParsingException;
38+
public int getServiceId() {
39+
return serviceId;
40+
}
41+
}

playlist/PlayListInfo.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.schabi.newpipe.extractor.playlist;
2+
3+
import org.schabi.newpipe.extractor.InfoItem;
4+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
5+
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector;
6+
7+
import java.util.List;
8+
import java.util.Vector;
9+
10+
public class PlayListInfo {
11+
12+
public void addException(Exception e) {
13+
errors.add(e);
14+
}
15+
16+
public static PlayListInfo getInfo(PlayListExtractor extractor) throws ParsingException {
17+
PlayListInfo info = new PlayListInfo();
18+
19+
info.playList_name = extractor.getName();
20+
info.hasNextPage = extractor.hasNextPage();
21+
22+
try {
23+
info.avatar_url = extractor.getAvatarUrl();
24+
} catch (Exception e) {
25+
info.errors.add(e);
26+
}
27+
try {
28+
info.banner_url = extractor.getBannerUrl();
29+
} catch (Exception e) {
30+
info.errors.add(e);
31+
}
32+
try {
33+
StreamInfoItemCollector c = extractor.getStreams();
34+
info.related_streams = c.getItemList();
35+
info.errors.addAll(c.getErrors());
36+
} catch(Exception e) {
37+
info.errors.add(e);
38+
}
39+
40+
return info;
41+
}
42+
43+
public int service_id = -1;
44+
public String playList_name = "";
45+
public String avatar_url = "";
46+
public String banner_url = "";
47+
public List<InfoItem> related_streams = null;
48+
public boolean hasNextPage = false;
49+
50+
public List<Throwable> errors = new Vector<>();
51+
}

playlist/PlayListInfoItem.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.schabi.newpipe.extractor.playlist;
2+
3+
import org.schabi.newpipe.extractor.InfoItem;
4+
5+
public class PlayListInfoItem implements InfoItem {
6+
7+
public int serviceId = -1;
8+
public String name = "";
9+
public String thumbnailUrl = "";
10+
public String webPageUrl = "";
11+
12+
public InfoType infoType() {
13+
return InfoType.PLAYLIST;
14+
}
15+
public String getTitle() {
16+
return name;
17+
}
18+
public String getLink() {
19+
return webPageUrl;
20+
}
21+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.schabi.newpipe.extractor.playlist;
2+
3+
import org.schabi.newpipe.extractor.InfoItemCollector;
4+
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
5+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
6+
7+
public class PlayListInfoItemCollector extends InfoItemCollector {
8+
public PlayListInfoItemCollector(int serviceId) {
9+
super(serviceId);
10+
}
11+
12+
public PlayListInfoItem extract(PlayListInfoItemExtractor extractor) throws ParsingException {
13+
final PlayListInfoItem resultItem = new PlayListInfoItem();
14+
15+
resultItem.name = extractor.getPlayListName();
16+
resultItem.serviceId = getServiceId();
17+
resultItem.webPageUrl = extractor.getWebPageUrl();
18+
try {
19+
resultItem.thumbnailUrl = extractor.getThumbnailUrl();
20+
} catch (Exception e) {
21+
addError(e);
22+
}
23+
return resultItem;
24+
}
25+
26+
public void commit(PlayListInfoItemExtractor extractor) throws ParsingException {
27+
try {
28+
addItem(extract(extractor));
29+
} catch (Exception e) {
30+
addError(e);
31+
}
32+
}
33+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.schabi.newpipe.extractor.playlist;
2+
3+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
4+
5+
public interface PlayListInfoItemExtractor {
6+
String getThumbnailUrl() throws ParsingException;
7+
String getPlayListName() throws ParsingException;
8+
String getWebPageUrl() throws ParsingException;
9+
}

0 commit comments

Comments
 (0)