-
Notifications
You must be signed in to change notification settings - Fork 417
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
[Bandcamp] Handle paywalled tracks #1033
Merged
Merged
Changes from all commits
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 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
.../java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPaidStreamExtractorTest.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.services.bandcamp; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.schabi.newpipe.downloader.DownloaderTestImpl; | ||
import org.schabi.newpipe.extractor.NewPipe; | ||
import org.schabi.newpipe.extractor.exceptions.ExtractionException; | ||
import org.schabi.newpipe.extractor.exceptions.PaidContentException; | ||
|
||
public class BandcampPaidStreamExtractorTest { | ||
|
||
@BeforeAll | ||
public static void setUp() { | ||
NewPipe.init(DownloaderTestImpl.getInstance()); | ||
} | ||
|
||
@Test | ||
public void testPaidTrack() throws ExtractionException { | ||
final var extractor = Bandcamp.getStreamExtractor("https://radicaldreamland.bandcamp.com/track/hackmud-continuous-mix"); | ||
assertThrows(PaidContentException.class, extractor::fetchPage); | ||
} | ||
} |
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.
Are you sure that all tracks that have no streamable track are paid tracks? Can't the reason be different in some cases?
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.
The other possible reason is that it is not available yet because the album is currently up for pre-order. For example, this album is right now: https://tamarmitchell.bandcamp.com/album/samos-return
However it is impossible to see whether all of the tracks can be played for free after the album is released, or whether the tracks will require purchase to play. Therefore I think it is an okay option to throw this exception in either case.
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.
I guess otherwise we could test for
unreleased_track
and throw a different exception if that is true. Is there an appropriate exception for this case? Otherwise I would stick withPaidContentException
.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.
Personally, I think
ContentNotAvailableException
is more appropriate, since the track is currently unavailable until the album is released, whether it's purchased or not.However, it seems like the tracks that can't be played due to the album being in pre-order do not have their own pages yet. Therefore, I don't think it's a case that can occur in the
StreamExtractor
. Going to the album in NewPipe and clicking on one of those tracks causes an error because the URL for them gets set tohttps://tamarmitchell.bandcamp.com/null
, so maybe it should be handled differently in thePlaylistExtractor
?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.
I see. I think I noticed the concatenation with
null
before but was unsure about the best way to fix it.