test
This commit is contained in:
parent
d2d975d3cc
commit
65a31fd37c
|
@ -23,30 +23,28 @@ import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||||
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
|
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
|
||||||
|
|
||||||
public class XhService extends StreamingService {
|
public class XhService extends StreamingService {
|
||||||
|
|
||||||
// name
|
// name
|
||||||
final static String NAME = "Xhamsters";
|
final static String NAME = "Xhamsters";
|
||||||
|
|
||||||
// host
|
// host
|
||||||
public final static String HOST = "xhamster18.desi";
|
public final static String HOST = "xhamster18.desi";
|
||||||
public final static String BASE_URL = "https://" + HOST + "/";
|
public final static String BASE_URL = "https://" + HOST + "/";
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
public XhService(final int id) {
|
public XhService(final int id) {
|
||||||
super(id, NAME, Arrays.asList(VIDEO));
|
super(id, NAME, Arrays.asList(VIDEO));
|
||||||
}
|
}
|
||||||
|
|
||||||
public XhService(int id, String name, List<ServiceInfo.MediaCapability> capabilities) {
|
public XhService(int id, String name, List<ServiceInfo.MediaCapability> capabilities) {
|
||||||
super(id, NAME, Arrays.asList(VIDEO));
|
super(id, NAME, Arrays.asList(VIDEO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBaseUrl() {
|
public String getBaseUrl() {
|
||||||
return BASE_URL;
|
return BASE_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchExtractor getSearchExtractor(SearchQueryHandler query) {
|
public SearchExtractor getSearchExtractor(SearchQueryHandler query) {
|
||||||
return new XhSearchExtractor(this, query);
|
return new XhSearchExtractor(this, query);
|
||||||
|
@ -76,7 +74,7 @@ public class XhService extends StreamingService {
|
||||||
public ListLinkHandlerFactory getCommentsLHFactory() {
|
public ListLinkHandlerFactory getCommentsLHFactory() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SuggestionExtractor getSuggestionExtractor() {
|
public SuggestionExtractor getSuggestionExtractor() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -89,11 +87,12 @@ public class XhService extends StreamingService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KioskList getKioskList() throws ExtractionException {
|
public KioskList getKioskList() throws ExtractionException {
|
||||||
final KioskList list = new KioskList(this);
|
// Return Empty List
|
||||||
|
// patch: if (kioskId == null) { return "" }
|
||||||
|
KioskList list = new KioskList(this);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException {
|
public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException {
|
||||||
return null;
|
return null;
|
||||||
|
@ -113,4 +112,4 @@ public class XhService extends StreamingService {
|
||||||
public CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler) throws ExtractionException {
|
public CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler) throws ExtractionException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
*
|
*
|
||||||
* @author Rakesh
|
* @author Rakesh
|
||||||
*/
|
*/
|
||||||
public abstract class XhStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
public class XhStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
||||||
|
|
||||||
XhVideo video;
|
XhVideo video;
|
||||||
|
|
||||||
public XhStreamInfoItemExtractor(XhVideo video) {
|
public XhStreamInfoItemExtractor(XhVideo video) {
|
||||||
|
@ -87,5 +87,5 @@ public abstract class XhStreamInfoItemExtractor implements StreamInfoItemExtract
|
||||||
public String getThumbnailUrl() throws ParsingException {
|
public String getThumbnailUrl() throws ParsingException {
|
||||||
return this.video.getThumbURL();
|
return this.video.getThumbURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,57 +5,62 @@
|
||||||
*/
|
*/
|
||||||
package org.schabi.newpipe.extractor.services.xh.extractors.items;
|
package org.schabi.newpipe.extractor.services.xh.extractors.items;
|
||||||
|
|
||||||
|
import com.grack.nanojson.JsonObject;
|
||||||
|
import com.grack.nanojson.JsonParser;
|
||||||
|
import com.grack.nanojson.JsonParserException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Rakesh
|
* @author Rakesh
|
||||||
*/
|
*/
|
||||||
public class XhVideo {
|
public class XhVideo {
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
String title;
|
String title;
|
||||||
String description;
|
String description;
|
||||||
|
|
||||||
int duration;
|
int duration;
|
||||||
int created;
|
int created;
|
||||||
|
|
||||||
String pageURL;
|
String pageURL;
|
||||||
String thumbURL;
|
String thumbURL;
|
||||||
|
|
||||||
int authorID;
|
int authorID;
|
||||||
String authorName;
|
String authorName;
|
||||||
String authorThumb;
|
String authorThumb;
|
||||||
String authorPageURL;
|
String authorPageURL;
|
||||||
|
|
||||||
Map<String, String> sources;
|
|
||||||
|
|
||||||
|
Map<String, String> sources = null;
|
||||||
|
|
||||||
public XhVideo(int id, String title, String description, int duration, int created, String pageURL, String thumbURL, int authorID, String authorName, String authorThumb, String authorPageURL, HashMap<String, String> streams) {
|
public XhVideo(int id, String title, String description, int duration, int created, String pageURL, String thumbURL, int authorID, String authorName, String authorThumb, String authorPageURL, HashMap<String, String> streams) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.created = created;
|
this.created = created;
|
||||||
|
|
||||||
this.pageURL = pageURL;
|
this.pageURL = pageURL;
|
||||||
this.thumbURL = thumbURL;
|
this.thumbURL = thumbURL;
|
||||||
|
|
||||||
this.authorID = authorID;
|
this.authorID = authorID;
|
||||||
this.authorName = authorName;
|
this.authorName = authorName;
|
||||||
this.authorThumb = authorThumb;
|
this.authorThumb = authorThumb;
|
||||||
this.authorPageURL = authorPageURL;
|
this.authorPageURL = authorPageURL;
|
||||||
|
|
||||||
this.sources = streams;
|
this.sources = streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +92,7 @@ public class XhVideo {
|
||||||
public String getAuthorName() {
|
public String getAuthorName() {
|
||||||
return authorName;
|
return authorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthorThumb() {
|
public String getAuthorThumb() {
|
||||||
return authorThumb;
|
return authorThumb;
|
||||||
}
|
}
|
||||||
|
@ -96,8 +101,47 @@ public class XhVideo {
|
||||||
return authorPageURL;
|
return authorPageURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getSourceURLs() throws IOException, JsonParserException {
|
||||||
|
/*
|
||||||
|
Parse
|
||||||
|
*/
|
||||||
|
Document html = Jsoup.connect(this.pageURL).get();
|
||||||
|
// Parse Content
|
||||||
|
String content = html.selectFirst("#initials-script").html();
|
||||||
|
String info_cdn = content.substring(0, content.length() - 1).replace("window.initials=", "");
|
||||||
|
|
||||||
|
// Use NanoJSON to convert to VideoItem
|
||||||
|
final JsonObject json = JsonParser.object().from(info_cdn);
|
||||||
|
final JsonObject videoModel = json.getObject("videoModel");
|
||||||
|
|
||||||
|
HashMap<String, String> streams = new HashMap<>();
|
||||||
|
|
||||||
|
// iterate urls
|
||||||
|
final JsonObject mp4 = videoModel.getObject("sources").getObject("mp4");
|
||||||
|
if (!mp4.isEmpty()) {
|
||||||
|
final Object keys[] = mp4.keySet().toArray();
|
||||||
|
for (int i = 0; i < keys.length; i++) {
|
||||||
|
final String key = keys[i].toString();
|
||||||
|
streams.put(key, mp4.getString("key"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return streams;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getSources() {
|
public Map<String, String> getSources() {
|
||||||
|
if (sources.isEmpty() || sources == null) {
|
||||||
|
// check if pageurl is set
|
||||||
|
if (!pageURL.isBlank() || !pageURL.isEmpty()) {
|
||||||
|
// parse the page
|
||||||
|
try {
|
||||||
|
this.sources = getSourceURLs();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue