-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
source-managers/src/main/java/com/dunctebot/sourcemanagers/pornhub/PHHelpers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.dunctebot.sourcemanagers.pornhub; | ||
|
||
import com.sedmelluq.discord.lavaplayer.tools.Units; | ||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; | ||
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; | ||
import org.jsoup.nodes.Element; | ||
|
||
public final class PHHelpers { | ||
public static AudioTrack trackFromSearchElement(Element element, PornHubAudioSourceManager mngr) { | ||
final var info = infoFromSearchElement(element); | ||
return new PornHubAudioTrack(info, mngr); | ||
} | ||
|
||
public static AudioTrackInfo infoFromSearchElement(Element element) { | ||
// TODO: parse min:sec duration | ||
// final var durText = element.getElementsByClass("duration").first().text(); | ||
|
||
// System.out.println(durText); | ||
|
||
final String title = element.getElementsByClass("title").first().text(); | ||
final String author = element.getElementsByClass("usernameWrap").first().text(); | ||
final long duration = Units.CONTENT_LENGTH_UNKNOWN; | ||
final String identifier = element.attr("data-video-vkey"); | ||
final String uri = "https://www.pornhub.com/view_video.php?viewkey=" + identifier; | ||
final String imageUrl = element.getElementsByTag("img").first().attr("src"); | ||
|
||
return new AudioTrackInfo( | ||
title, author, duration, identifier, false, uri, imageUrl, null | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2022 Duncan "duncte123" Sterken | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import com.dunctebot.sourcemanagers.pornhub.PornHubAudioSourceManager; | ||
import com.dunctebot.sourcemanagers.pornhub.PornHubAudioTrack; | ||
import com.sedmelluq.discord.lavaplayer.track.AudioReference; | ||
|
||
public class PHSearchTest { | ||
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=ph6383940fcb8d7"; | ||
final var mngr = new PornHubAudioSourceManager(); | ||
|
||
final var test = mngr.attemptSearch("minecraft bedwards"); | ||
|
||
System.out.println(test); | ||
} | ||
} |