Skip to content

Commit

Permalink
Fix pornhub playback
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
duncte123 committed Nov 26, 2023
1 parent 1e89b4e commit 9632854
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ fun VersionCatalogBuilder.common() {
}

fun VersionCatalogBuilder.sourceManager() {
version("slf4j-version", "2.0.9")

library("lavaplayer", "dev.arbjerg", "lavaplayer").version("2.0.3")
library("logger", "org.slf4j", "slf4j-api").version("2.0.7")
library("logger", "org.slf4j", "slf4j-api").versionRef("slf4j-version")
library("logger-impl", "org.slf4j", "slf4j-simple").versionRef("slf4j-version")
library("commonsIo", "commons-io", "commons-io").version("2.7")
library("jsoup", "org.jsoup", "jsoup").version("1.15.3")
library("findbugs", "com.google.code.findbugs", "jsr305").version("3.0.2")
Expand Down
1 change: 1 addition & 0 deletions source-managers/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation(libs.findbugs)

testImplementation(libs.lavaplayer)
testImplementation(libs.logger.impl)
}

configure<JavaPluginExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ private OCRTrackMeta extractTrackData(Element elem) {
return null;
}

System.out.println(remix.html());

final String remixers = elem.selectFirst("remixers")
.children()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -79,16 +81,26 @@ public String loadFromMediaInfo() throws IOException {

int i = 0;
while (!defs.index(i).isNull()) {
final JsonBrowser definition = defs.index(i);
// we found the default quality
if ("mp4".equalsIgnoreCase(defs.index(i).get("format").safeText())) {
if ("mp4".equalsIgnoreCase(definition.get("format").safeText())) {
final String cookies = Arrays.stream(response.getHeaders("Set-Cookie"))
.map(NameValuePair::getValue)
.map((s) -> s.split(";", 2)[0])
.collect(Collectors.joining("; "));
final String getMedia = parseJsValueToUrl(
/*final String getMedia = parseJsValueToUrl(
html,
scoupMediaVar(html, "media_" + i)
);
);*/
String getMedia = definition.get("videoUrl").safeText();

if (getMedia.isBlank()) {
// Try the old way when the videoUrl is blank.
getMedia = parseJsValueToUrl(
html,
scoupMediaVar(html, "media_" + i)
);
}

return loadMp4Url(getMedia, cookies);
}
Expand Down
3 changes: 2 additions & 1 deletion source-managers/src/test/java/PHtest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

public class PHtest {
public static void main(String[] args) throws Exception {
final var link = "https://www.pornhub.com/view_video.php?viewkey=ph5fc5ef73cfc87";
// final var link = "https://www.pornhub.com/view_video.php?viewkey=ph5fc5ef73cfc87";
final var link = "https://www.pornhub.com/view_video.php?viewkey=ph6383940fcb8d7";
final var mngr = new PornHubAudioSourceManager();

final var track = (PornHubAudioTrack) mngr.loadItem(null, new AudioReference(link, null));
Expand Down

0 comments on commit 9632854

Please sign in to comment.