Skip to content
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

Remove unused methods #846

Merged
merged 2 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.localization.Localization;

import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;

/**
* Provides access to streaming services supported by NewPipe.
Expand Down Expand Up @@ -92,24 +93,6 @@ public static StreamingService getServiceByUrl(final String url) throws Extracti
throw new ExtractionException("No service can handle the url = \"" + url + "\"");
}

public static int getIdOfService(final String serviceName) {
try {
return getService(serviceName).getServiceId();
} catch (final ExtractionException ignored) {
return -1;
}
}

public static String getNameOfService(final int id) {
try {
return getService(id).getServiceInfo().getName();
} catch (final Exception e) {
System.err.println("Service id not known");
e.printStackTrace();
return "<unknown>";
}
}

/*//////////////////////////////////////////////////////////////////////////
// Localization
//////////////////////////////////////////////////////////////////////////*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.schabi.newpipe.extractor;

import org.junit.jupiter.api.Test;

import java.util.HashSet;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;

import org.junit.jupiter.api.Test;

import java.util.HashSet;

public class NewPipeTest {
@Test
public void getAllServicesTest() throws Exception {
Expand All @@ -17,8 +18,8 @@ public void getAllServicesTest() throws Exception {

@Test
public void testAllServicesHaveDifferentId() throws Exception {
HashSet<Integer> servicesId = new HashSet<>();
for (StreamingService streamingService : NewPipe.getServices()) {
final HashSet<Integer> servicesId = new HashSet<>();
for (final StreamingService streamingService : NewPipe.getServices()) {
final String errorMsg =
"There are services with the same id = " + streamingService.getServiceId()
+ " (current service > " + streamingService.getServiceInfo().getName() + ")";
Expand All @@ -32,11 +33,6 @@ public void getServiceWithId() throws Exception {
assertEquals(NewPipe.getService(YouTube.getServiceId()), YouTube);
}

@Test
public void getServiceWithName() throws Exception {
assertEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), YouTube);
}

@Test
public void getServiceWithUrl() throws Exception {
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube);
Expand All @@ -47,14 +43,4 @@ public void getServiceWithUrl() throws Exception {
assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud);
assertEquals(getServiceByUrl("https://www.google.com/url?sa=t&url=https%3A%2F%2Fsoundcloud.com%2Fciaoproduction&rct=j&q=&esrc=s&source=web&cd="), SoundCloud);
}

@Test
public void getIdWithServiceName() throws Exception {
assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().getName()), YouTube.getServiceId());
}

@Test
public void getServiceNameWithId() throws Exception {
assertEquals(NewPipe.getNameOfService(YouTube.getServiceId()), YouTube.getServiceInfo().getName());
}
}