Add "originalUrl" field to Info's object
This commit is contained in:
parent
3fe9922d49
commit
77a74b8d20
6 changed files with 38 additions and 16 deletions
|
@ -13,7 +13,19 @@ public abstract class Info implements Serializable {
|
|||
* e.g. Youtube: https://www.youtube.com/watch?v=RER5qCTzZ7 > RER5qCTzZ7
|
||||
*/
|
||||
private final String id;
|
||||
/**
|
||||
* Different than the {@link #originalUrl} in the sense that it <i>may</i> be set as a cleaned url.
|
||||
*
|
||||
* @see UrlIdHandler#cleanUrl(String)
|
||||
* @see Extractor#getCleanUrl()
|
||||
*/
|
||||
private final String url;
|
||||
/**
|
||||
* The url used to start the extraction of this {@link Info} object.
|
||||
*
|
||||
* @see Extractor#getOriginalUrl()
|
||||
*/
|
||||
private final String originalUrl;
|
||||
private final String name;
|
||||
|
||||
private final List<Throwable> errors = new ArrayList<>();
|
||||
|
@ -26,16 +38,18 @@ public abstract class Info implements Serializable {
|
|||
this.errors.addAll(errors);
|
||||
}
|
||||
|
||||
public Info(int serviceId, String id, String url, String name) {
|
||||
public Info(int serviceId, String id, String url, String originalUrl, String name) {
|
||||
this.serviceId = serviceId;
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.originalUrl = originalUrl;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "[url=\"" + url + "\", name=\"" + name + "\"]";
|
||||
final String ifDifferentString = !url.equals(originalUrl) ? " (originalUrl=\"" + originalUrl + "\")" : "";
|
||||
return getClass().getSimpleName() + "[url=\"" + url + "\"" + ifDifferentString + ", name=\"" + name + "\"]";
|
||||
}
|
||||
|
||||
public int getServiceId() {
|
||||
|
@ -50,6 +64,10 @@ public abstract class Info implements Serializable {
|
|||
return url;
|
||||
}
|
||||
|
||||
public String getOriginalUrl() {
|
||||
return originalUrl;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ public abstract class ListInfo<T extends InfoItem> extends Info {
|
|||
private List<T> relatedItems;
|
||||
private String nextPageUrl = null;
|
||||
|
||||
public ListInfo(int serviceId, String id, String url, String name) {
|
||||
super(serviceId, id, url, name);
|
||||
public ListInfo(int serviceId, String id, String url, String originalUrl, String name) {
|
||||
super(serviceId, id, url, originalUrl, name);
|
||||
}
|
||||
|
||||
public List<T> getRelatedItems() {
|
||||
|
|
|
@ -32,8 +32,8 @@ import java.io.IOException;
|
|||
|
||||
public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||
|
||||
public ChannelInfo(int serviceId, String url, String id, String name) {
|
||||
super(serviceId, id, url, name);
|
||||
public ChannelInfo(int serviceId, String id, String url, String originalUrl, String name) {
|
||||
super(serviceId, id, url, originalUrl, name);
|
||||
}
|
||||
|
||||
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
|
||||
|
@ -55,10 +55,11 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
|||
// important data
|
||||
int serviceId = extractor.getServiceId();
|
||||
String url = extractor.getCleanUrl();
|
||||
String originalUrl = extractor.getOriginalUrl();
|
||||
String id = extractor.getId();
|
||||
String name = extractor.getName();
|
||||
|
||||
ChannelInfo info = new ChannelInfo(serviceId, url, id, name);
|
||||
ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name);
|
||||
|
||||
|
||||
try {
|
||||
|
|
|
@ -32,8 +32,8 @@ import java.io.IOException;
|
|||
|
||||
public class KioskInfo extends ListInfo<StreamInfoItem> {
|
||||
|
||||
private KioskInfo(int serviceId, String id, String url, String name) {
|
||||
super(serviceId, id, url, name);
|
||||
private KioskInfo(int serviceId, String id, String url, String originalUrl, String name) {
|
||||
super(serviceId, id, url, originalUrl, name);
|
||||
}
|
||||
|
||||
public static ListExtractor.InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
|
||||
|
@ -72,8 +72,9 @@ public class KioskInfo extends ListInfo<StreamInfoItem> {
|
|||
String name = extractor.getName();
|
||||
String id = extractor.getId();
|
||||
String url = extractor.getCleanUrl();
|
||||
String originalUrl = extractor.getOriginalUrl();
|
||||
|
||||
KioskInfo info = new KioskInfo(serviceId, id, name, url);
|
||||
KioskInfo info = new KioskInfo(serviceId, id, url, originalUrl, name);
|
||||
|
||||
final ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
||||
info.setRelatedItems(itemsPage.getItems());
|
||||
|
|
|
@ -12,8 +12,8 @@ import java.io.IOException;
|
|||
|
||||
public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||
|
||||
public PlaylistInfo(int serviceId, String id, String url, String name) {
|
||||
super(serviceId, id, url, name);
|
||||
public PlaylistInfo(int serviceId, String id, String url, String originalUrl, String name) {
|
||||
super(serviceId, id, url, originalUrl, name);
|
||||
}
|
||||
|
||||
public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException {
|
||||
|
@ -39,9 +39,10 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
|||
|
||||
int serviceId = extractor.getServiceId();
|
||||
String url = extractor.getCleanUrl();
|
||||
String originalUrl = extractor.getOriginalUrl();
|
||||
String id = extractor.getId();
|
||||
String name = extractor.getName();
|
||||
PlaylistInfo info = new PlaylistInfo(serviceId, id, url, name);
|
||||
PlaylistInfo info = new PlaylistInfo(serviceId, id, url, originalUrl, name);
|
||||
|
||||
try {
|
||||
info.setStreamCount(extractor.getStreamCount());
|
||||
|
|
|
@ -41,8 +41,8 @@ public class StreamInfo extends Info {
|
|||
}
|
||||
}
|
||||
|
||||
public StreamInfo(int serviceId, String url, StreamType streamType, String id, String name, int ageLimit) {
|
||||
super(serviceId, id, url, name);
|
||||
public StreamInfo(int serviceId, String url, String originalUrl, StreamType streamType, String id, String name, int ageLimit) {
|
||||
super(serviceId, id, url, originalUrl, name);
|
||||
this.streamType = streamType;
|
||||
this.ageLimit = ageLimit;
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ public class StreamInfo extends Info {
|
|||
|
||||
int serviceId = extractor.getServiceId();
|
||||
String url = extractor.getCleanUrl();
|
||||
String originalUrl = extractor.getOriginalUrl();
|
||||
StreamType streamType = extractor.getStreamType();
|
||||
String id = extractor.getId();
|
||||
String name = extractor.getName();
|
||||
|
@ -99,7 +100,7 @@ public class StreamInfo extends Info {
|
|||
throw new ExtractionException("Some important stream information was not given.");
|
||||
}
|
||||
|
||||
return new StreamInfo(serviceId, url, streamType, id, name, ageLimit);
|
||||
return new StreamInfo(serviceId, url, originalUrl, streamType, id, name, ageLimit);
|
||||
}
|
||||
|
||||
private static StreamInfo extractStreams(StreamInfo streamInfo, StreamExtractor extractor) throws ExtractionException {
|
||||
|
|
Loading…
Reference in a new issue