Skip to content

Commit

Permalink
Changed default client to ANDROID_TESTSUITE
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeucelli committed Aug 10, 2024
1 parent 02900a0 commit 91e7fbb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/com/github/felipeucelli/javatube/Youtube.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Youtube {
public Youtube(String url) throws Exception {
urlVideo = url;
watchUrl = "https://www.youtube.com/watch?v=" + videoId();
client = "ANDROID_TESTSUITE";
innerTube = new InnerTube(client);
}
/**
* @Clients:
Expand Down Expand Up @@ -78,7 +80,7 @@ public String toString(){
}

private String setHtml() throws Exception {
Map<String, String> headers = innerTube == null ? null : innerTube.getClientHeaders();
Map<String, String> headers = new InnerTube("WEB").getClientHeaders();
return Request.get(watchUrl, headers).toString(StandardCharsets.UTF_8.name()).replace("\n", "");
}

Expand All @@ -103,9 +105,10 @@ public JSONObject getSignatureTimestamp() throws Exception {
if(signatureTimestamp == null){
signatureTimestamp = new JSONObject(
"{" +
"playbackContext:{" +
"contentPlaybackContext: {" +
"signatureTimestamp:" + setSignatureTimestamp() +
"\"playbackContext\": {" +
"\"contentPlaybackContext\": {" +
"\"signatureTimestamp\": " + setSignatureTimestamp() + "," +
"\"referer\": \"https://www.youtube.com/watch?v=" + videoId() + "\"" +
"}" +
"}" +
"}"
Expand Down Expand Up @@ -379,7 +382,7 @@ public Integer length() throws Exception {
}

public String getThumbnailUrl() throws Exception {
JSONArray thumbnails = getVidInfo().getJSONObject("videoDetails")
JSONArray thumbnails = new InnerTube("WEB").player(videoId()).getJSONObject("videoDetails")
.getJSONObject("thumbnail")
.getJSONArray("thumbnails");
return thumbnails.getJSONObject(thumbnails.length() - 1).getString("url");
Expand All @@ -397,7 +400,7 @@ public String getAuthor() throws Exception {

public ArrayList<Captions> getCaptionTracks() throws Exception {
try{
JSONArray rawTracks = getVidInfo().getJSONObject("captions")
JSONArray rawTracks = new InnerTube("WEB").player(videoId()).getJSONObject("captions")
.getJSONObject("playerCaptionsTracklistRenderer")
.getJSONArray("captionTracks");
ArrayList<Captions> captions = new ArrayList<>();
Expand Down

0 comments on commit 91e7fbb

Please sign in to comment.