Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
Updated javadoc

Cleanup more code

* Improve /Add java doc
* Remove unused code
* Convert TODOs to followup issues
  • Loading branch information
litetex committed Jun 24, 2022
1 parent 48a9fd3 commit 1987678
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public BandcampSearchStreamInfoItemExtractor(final Element searchResult,
public String getUploaderName() {
final String subhead = resultInfo.getElementsByClass("subhead").text();
final String[] splitBy = subhead.split("by ");
return splitBy.length > 1 ? splitBy[1] : splitBy[0];
return splitBy[splitBy.length > 1 ? 1 : 0];
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ public List<VideoAudioStream> getVideoStreams() throws IOException, ExtractionEx
dto.getStreamJsonObj().getArray("videoSize");

return new SimpleVideoAudioStreamImpl(
// TODO: This looks wrong
new VideoAudioFormatRegistry()
.getFromSuffixOrThrow(dto.getUrlKey()),
buildDeliveryData(dto),
Expand Down Expand Up @@ -234,4 +233,31 @@ public boolean isLive() {
public String getCategory() {
return group;
}

static final class MediaCCCLiveStreamMapperDTO {
private final JsonObject streamJsonObj;
private final String urlKey;
private final JsonObject urlValue;

MediaCCCLiveStreamMapperDTO(final JsonObject streamJsonObj,
final String urlKey,
final JsonObject urlValue) {
this.streamJsonObj = streamJsonObj;
this.urlKey = urlKey;
this.urlValue = urlValue;
}

JsonObject getStreamJsonObj() {
return streamJsonObj;
}

String getUrlKey() {
return urlKey;
}

JsonObject getUrlValue() {
return urlValue;
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ private void tryExtractSubtitles() {
baseUrl + JsonUtils.getString(caption, "captionPath");

return new SimpleSubtitleStreamImpl(
// TODO: Check for null
new SubtitleFormatRegistry()
.getFromSuffixOrThrow(
url.substring(url.lastIndexOf(".") + 1)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private List<AudioStream> extractAudioStreams() {
return null;
}

return (AudioStream) new SimpleAudioStreamImpl(
return new SimpleAudioStreamImpl(
mediaFormat,
protocol.equals("hls")
? new SimpleHLSDeliveryDataImpl(mediaUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

// TODO: Doc
/**
* Abstract class for YouTube DASH manifest creation.
*
* <p>
* This class includes common methods of manifest creators and useful constants.
* </p>
*
* <p>
* Generation of DASH documents and their conversion as a string is done using external classes
* from {@link org.w3c.dom} and {@link javax.xml} packages.
* </p>
*/
public abstract class AbstractYoutubeDashManifestCreator implements DashManifestCreator {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ public List<AudioStream> getAudioStreams() throws ExtractionException {

@Override
public List<VideoAudioStream> getVideoStreams() throws ExtractionException {
return buildStrems(FORMATS,
return buildStrems(
FORMATS,
ItagFormatRegistry.VIDEO_AUDIO_FORMATS,
(itagInfo, deliveryData) -> new SimpleVideoAudioStreamImpl(
itagInfo.getItagFormat().mediaFormat(),
Expand Down Expand Up @@ -1199,6 +1200,19 @@ I extends ItagFormat<?>> List<T> buildStrems(
}
}

/*
* Note: We build the manifests for YT ourself because the provided ones (according to AudricV)
* <ul>
* <li>aren't working https://github.com/google/ExoPlayer/issues/2422#issuecomment-283080031
* </li>
* <li>causes memory problems; TransactionTooLargeException: data parcel size 3174340</li>
* <li>are not always returned, only for videos with OTF streams, or on (ended or not)
* livestreams</li>
* <li>Instead of downloading a 10MB manifest when you can generate one which is 1 or 2MB
* large</li>
* <li>Also, this manifest isn't used at all by modern YouTube clients.</li>
* </ul>
*/
@Nonnull
private <I extends ItagFormat<?>> DeliveryData buildDeliveryData(final ItagInfo<I> itagInfo) {
final ItagFormatDeliveryData iDeliveryData = itagInfo.getItagFormat().deliveryData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
import java.util.stream.Stream;

// CHECKSTYLE:OFF - Link is too long
// https://github.com/ytdl-org/youtube-dl/blob/9aa8e5340f3d5ece372b983f8e399277ca1f1fe4/youtube_dl/extractor/youtube.py#L1195
/**
* A registry that contains all supported YouTube itags.
* <p>
* For additional information you may also check:
* <ul>
* <li>https://github.com/ytdl-org/youtube-dl/blob/9aa8e5340f3d5ece372b983f8e399277ca1f1fe4/youtube_dl/extractor/youtube.py#L1195</li>
* <li>https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f</li>
* </ul>
*/
// CHECKSTYLE:ON
public final class ItagFormatRegistry {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class ItagInfo<I extends ItagFormat<?>> {
@Nonnull
private final I itagFormat;

// TODO: Maybe generate the streamUrl on-demand and not always instantly?
@Nonnull
private final String streamUrl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public final class DashManifestCreatorConstants {
private DashManifestCreatorConstants() {
// No impl!
// No impl
}

// XML elements of DASH MPD manifests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@

import javax.annotation.Nonnull;

/**
* Note we build the manifests for YT ourself because the provided ones (according to TiA4f8R)
* <ul>
* <li>aren't working https://github.com/google/ExoPlayer/issues/2422#issuecomment-283080031</li>
* <li>causes memory problems; TransactionTooLargeException: data parcel size 3174340</li>
* <li>are not always returned, only for videos with OTF streams, or on (ended or not)
* livestreams</li>
* <li>Instead of downloading a 10MB manifest when you can generate one which is 1 or 2MB large</li>
* <li>Also, this manifest isn't used at all by modern YouTube clients.</li>
* </ul>
*/
public class SimpleDASHManifestDeliveryDataImpl extends AbstractDeliveryDataImpl
implements DASHManifestDeliveryData {
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public SimpleVideoAudioStreamImpl(
this(mediaFormat, deliveryData, videoQualityData, UNKNOWN_AVG_BITRATE);
}

public SimpleVideoAudioStreamImpl(
@Nonnull final VideoAudioMediaFormat mediaFormat,
@Nonnull final DeliveryData deliveryData
) {
this(mediaFormat, deliveryData, VideoQualityData.fromUnknown());
}

@Nonnull
@Override
public VideoQualityData videoQualityData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Objects;

/**
* class to create a pair of objects.
* Class to create a pair of objects.
*
*
* <p>
Expand Down

0 comments on commit 1987678

Please sign in to comment.