Skip to content

Commit

Permalink
[YouTube] Fix checkstyle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Mar 18, 2022
1 parent d6f72ca commit 9ee52ae
Show file tree
Hide file tree
Showing 27 changed files with 689 additions and 425 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package org.schabi.newpipe.extractor.services.youtube;

import static org.schabi.newpipe.extractor.MediaFormat.M4A;
import static org.schabi.newpipe.extractor.MediaFormat.MPEG_4;
import static org.schabi.newpipe.extractor.MediaFormat.WEBM;
import static org.schabi.newpipe.extractor.MediaFormat.WEBMA;
import static org.schabi.newpipe.extractor.MediaFormat.WEBMA_OPUS;
import static org.schabi.newpipe.extractor.MediaFormat.v3GPP;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.ItagType.AUDIO;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.ItagType.VIDEO;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.ItagType.VIDEO_ONLY;

import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.exceptions.ParsingException;

import static org.schabi.newpipe.extractor.MediaFormat.*;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.ItagType.*;

public class ItagItem {
/**
* List can be found here https://github.com/ytdl-org/youtube-dl/blob/9fc5eafb8e384453a49f7cfe73147be491f0b19d/youtube_dl/extractor/youtube.py#L1071
* List can be found here
* https://github.com/ytdl-org/youtube-dl/blob/9fc5eafb8e384453a49f7cfe73147be491f0b19d/youtube_dl/extractor/youtube.py#L1071
*/
private static final ItagItem[] ITAG_LIST = {
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -79,17 +87,17 @@ public class ItagItem {
// Utils
//////////////////////////////////////////////////////////////////////////*/

public static boolean isSupported(int itag) {
for (ItagItem item : ITAG_LIST) {
public static boolean isSupported(final int itag) {
for (final ItagItem item : ITAG_LIST) {
if (itag == item.id) {
return true;
}
}
return false;
}

public static ItagItem getItag(int itagId) throws ParsingException {
for (ItagItem item : ITAG_LIST) {
public static ItagItem getItag(final int itagId) throws ParsingException {
for (final ItagItem item : ITAG_LIST) {
if (itagId == item.id) {
return item;
}
Expand All @@ -110,7 +118,10 @@ public enum ItagType {
/**
* Call {@link #ItagItem(int, ItagType, MediaFormat, String, int)} with the fps set to 30.
*/
public ItagItem(int id, ItagType type, MediaFormat format, String resolution) {
public ItagItem(final int id,
final ItagType type,
final MediaFormat format,
final String resolution) {
this.id = id;
this.itagType = type;
this.mediaFormat = format;
Expand All @@ -123,15 +134,22 @@ public ItagItem(int id, ItagType type, MediaFormat format, String resolution) {
*
* @param resolution string that will be used in the frontend
*/
public ItagItem(int id, ItagType type, MediaFormat format, String resolution, int fps) {
public ItagItem(final int id,
final ItagType type,
final MediaFormat format,
final String resolution,
final int fps) {
this.id = id;
this.itagType = type;
this.mediaFormat = format;
this.resolutionString = resolution;
this.fps = fps;
}

public ItagItem(int id, ItagType type, MediaFormat format, int avgBitrate) {
public ItagItem(final int id,
final ItagType type,
final MediaFormat format,
final int avgBitrate) {
this.id = id;
this.itagType = type;
this.mediaFormat = format;
Expand Down Expand Up @@ -170,71 +188,71 @@ public int getBitrate() {
return bitrate;
}

public void setBitrate(int bitrate) {
public void setBitrate(final int bitrate) {
this.bitrate = bitrate;
}

public int getWidth() {
return width;
}

public void setWidth(int width) {
public void setWidth(final int width) {
this.width = width;
}

public int getHeight() {
return height;
}

public void setHeight(int height) {
public void setHeight(final int height) {
this.height = height;
}

public int getInitStart() {
return initStart;
}

public void setInitStart(int initStart) {
public void setInitStart(final int initStart) {
this.initStart = initStart;
}

public int getInitEnd() {
return initEnd;
}

public void setInitEnd(int initEnd) {
public void setInitEnd(final int initEnd) {
this.initEnd = initEnd;
}

public int getIndexStart() {
return indexStart;
}

public void setIndexStart(int indexStart) {
public void setIndexStart(final int indexStart) {
this.indexStart = indexStart;
}

public int getIndexEnd() {
return indexEnd;
}

public void setIndexEnd(int indexEnd) {
public void setIndexEnd(final int indexEnd) {
this.indexEnd = indexEnd;
}

public String getQuality() {
return quality;
}

public void setQuality(String quality) {
public void setQuality(final String quality) {
this.quality = quality;
}

public String getCodec() {
return codec;
}

public void setCodec(String codec) {
public void setCodec(final String codec) {
this.codec = codec;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* This class handling fetching the JavaScript file in order to allow other classes to extract the
* needed functions.
*/
public class YoutubeJavaScriptExtractor {
public final class YoutubeJavaScriptExtractor {

private static final String HTTPS = "https:";
private static String cachedJavaScriptCode;
Expand Down Expand Up @@ -81,9 +81,10 @@ public static String extractJavaScriptUrl() throws ParsingException {
final String hashPattern = "player\\\\\\/([a-z0-9]{8})\\\\\\/";
final String hash = Parser.matchGroup1(hashPattern, iframeContent);

return String.format("https://www.youtube.com/s/player/%s/player_ias.vflset/en_US/base.js", hash);

} catch (final Exception i) { }
return String.format(
"https://www.youtube.com/s/player/%s/player_ias.vflset/en_US/base.js", hash);
} catch (final Exception ignored) {
}

throw new ParsingException("Iframe API did not provide YouTube player js url");
}
Expand All @@ -109,8 +110,8 @@ public static String extractJavaScriptUrl(final String videoId) throws ParsingEx
}
}
}

} catch (final Exception i) { }
} catch (final Exception ignored) {
}

throw new ParsingException("Embedded info did not provide YouTube player js url");
}
Expand Down
Loading

0 comments on commit 9ee52ae

Please sign in to comment.