File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414import org .schabi .newpipe .extractor .exceptions .ParsingException ;
1515import org .schabi .newpipe .extractor .exceptions .ReCaptchaException ;
1616import org .schabi .newpipe .extractor .linkhandler .LinkHandler ;
17+ import org .schabi .newpipe .extractor .playlist .PlaylistInfoItemsCollector ;
1718import org .schabi .newpipe .extractor .stream .AudioStream ;
1819import org .schabi .newpipe .extractor .stream .Description ;
1920import org .schabi .newpipe .extractor .stream .StreamSegment ;
@@ -165,4 +166,10 @@ public List<String> getTags() {
165166 public Privacy getPrivacy () {
166167 return Privacy .PUBLIC ;
167168 }
169+
170+ @ Override
171+ public PlaylistInfoItemsCollector getRelatedItems () {
172+ // Contrary to other Bandcamp streams, radio streams don't have related items
173+ return null ;
174+ }
168175}
Original file line number Diff line number Diff line change 1+ // Created by Fynn Godau 2021, licensed GNU GPL version 3 or later
2+
3+ package org .schabi .newpipe .extractor .services .bandcamp .extractors ;
4+
5+ import org .jsoup .nodes .Element ;
6+ import org .schabi .newpipe .extractor .exceptions .ParsingException ;
7+ import org .schabi .newpipe .extractor .playlist .PlaylistInfoItemExtractor ;
8+
9+ import javax .annotation .Nonnull ;
10+
11+ /**
12+ * Extracts recommended albums from tracks' website
13+ */
14+ public class BandcampRelatedPlaylistInfoItemExtractor implements PlaylistInfoItemExtractor {
15+ private final Element relatedAlbum ;
16+
17+ public BandcampRelatedPlaylistInfoItemExtractor (@ Nonnull Element relatedAlbum ) {
18+ this .relatedAlbum = relatedAlbum ;
19+ }
20+
21+ @ Override
22+ public String getName () throws ParsingException {
23+ return relatedAlbum .getElementsByClass ("release-title" ).text ();
24+ }
25+
26+ @ Override
27+ public String getUrl () throws ParsingException {
28+ return relatedAlbum .getElementsByClass ("title-and-artist" ).attr ("abs:href" );
29+ }
30+
31+ @ Override
32+ public String getThumbnailUrl () throws ParsingException {
33+ return relatedAlbum .getElementsByClass ("album-art" ).attr ("src" );
34+ }
35+
36+ @ Override
37+ public String getUploaderName () throws ParsingException {
38+ return relatedAlbum .getElementsByClass ("by-artist" ).text ().replace ("by " , "" );
39+ }
40+
41+ @ Override
42+ public long getStreamCount () throws ParsingException {
43+ return -1 ;
44+ }
45+ }
Original file line number Diff line number Diff line change 1616import org .schabi .newpipe .extractor .exceptions .ParsingException ;
1717import org .schabi .newpipe .extractor .linkhandler .LinkHandler ;
1818import org .schabi .newpipe .extractor .localization .DateWrapper ;
19+ import org .schabi .newpipe .extractor .playlist .PlaylistInfoItemsCollector ;
1920import org .schabi .newpipe .extractor .stream .*;
2021import org .schabi .newpipe .extractor .utils .JsonUtils ;
2122import org .schabi .newpipe .extractor .utils .Utils ;
@@ -245,8 +246,17 @@ public StreamType getStreamType() {
245246 }
246247
247248 @ Override
248- public StreamInfoItemsCollector getRelatedItems () {
249- return null ;
249+ public PlaylistInfoItemsCollector getRelatedItems () {
250+
251+ PlaylistInfoItemsCollector collector = new PlaylistInfoItemsCollector (getServiceId ());
252+
253+ Elements recommendedAlbums = document .getElementsByClass ("recommended-album" );
254+
255+ for (Element album : recommendedAlbums ) {
256+ collector .commit (new BandcampRelatedPlaylistInfoItemExtractor (album ));
257+ }
258+
259+ return collector ;
250260 }
251261
252262 @ Override
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ public boolean expectedHasVideoStreams() {
126126
127127 @ Override
128128 public boolean expectedHasRelatedItems () {
129- return false ;
129+ return true ;
130130 }
131131
132132 @ Override
You can’t perform that action at this time.
0 commit comments