Use Java 8 streams in NewPipe class
This commit is contained in:
parent
c2446ecff0
commit
08dff33002
1 changed files with 12 additions and 14 deletions
|
@ -71,22 +71,20 @@ public final class NewPipe {
|
||||||
return ServiceList.all();
|
return ServiceList.all();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamingService getService(int serviceId) throws ExtractionException {
|
public static StreamingService getService(final int serviceId) throws ExtractionException {
|
||||||
for (StreamingService service : ServiceList.all()) {
|
return ServiceList.all().stream()
|
||||||
if (service.getServiceId() == serviceId) {
|
.filter(service -> service.getServiceId() == serviceId)
|
||||||
return service;
|
.findFirst()
|
||||||
}
|
.orElseThrow(() -> new ExtractionException(
|
||||||
}
|
"There's no service with the id = \"" + serviceId + "\""));
|
||||||
throw new ExtractionException("There's no service with the id = \"" + serviceId + "\"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamingService getService(String serviceName) throws ExtractionException {
|
public static StreamingService getService(final String serviceName) throws ExtractionException {
|
||||||
for (StreamingService service : ServiceList.all()) {
|
return ServiceList.all().stream()
|
||||||
if (service.getServiceInfo().getName().equals(serviceName)) {
|
.filter(service -> service.getServiceInfo().getName().equals(serviceName))
|
||||||
return service;
|
.findFirst()
|
||||||
}
|
.orElseThrow(() -> new ExtractionException(
|
||||||
}
|
"There's no service with the name = \"" + serviceName + "\""));
|
||||||
throw new ExtractionException("There's no service with the name = \"" + serviceName + "\"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamingService getServiceByUrl(final String url) throws ExtractionException {
|
public static StreamingService getServiceByUrl(final String url) throws ExtractionException {
|
||||||
|
|
Loading…
Reference in a new issue