diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java index f4482ff2e9..aef11ba598 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java @@ -106,7 +106,7 @@ public static boolean isSupported(final int itag) { public static ItagItem getItag(final int itagId) throws ParsingException { for (final ItagItem item : ITAG_LIST) { if (itagId == item.id) { - return item; + return new ItagItem(item); } } throw new ParsingException("itag " + itagId + " is not supported"); @@ -173,6 +173,34 @@ public ItagItem(final int id, this.avgBitrate = avgBitrate; } + /** + * Copy constructor of the {@link ItagItem} class. + * + * @param itagItem the {@link ItagItem} to copy its properties into a new {@link ItagItem} + */ + public ItagItem(@Nonnull final ItagItem itagItem) { + this.mediaFormat = itagItem.mediaFormat; + this.id = itagItem.id; + this.itagType = itagItem.itagType; + this.avgBitrate = itagItem.avgBitrate; + this.sampleRate = itagItem.sampleRate; + this.audioChannels = itagItem.audioChannels; + this.resolutionString = itagItem.resolutionString; + this.fps = itagItem.fps; + this.bitrate = itagItem.bitrate; + this.width = itagItem.width; + this.height = itagItem.height; + this.initStart = itagItem.initStart; + this.initEnd = itagItem.initEnd; + this.indexStart = itagItem.indexStart; + this.indexEnd = itagItem.indexEnd; + this.quality = itagItem.quality; + this.codec = itagItem.codec; + this.targetDurationSec = itagItem.targetDurationSec; + this.approxDurationMs = itagItem.approxDurationMs; + this.contentLength = itagItem.contentLength; + } + public MediaFormat getMediaFormat() { return mediaFormat; }