Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ public ItagItem(@Nonnull final ItagItem itagItem) {
this.audioTrackName = itagItem.audioTrackName;
this.audioTrackType = itagItem.audioTrackType;
this.audioLocale = itagItem.audioLocale;
this.isDrc = itagItem.isDrc;
this.lastModified = itagItem.lastModified;
this.xtags = itagItem.xtags;
this.autoGenerated = itagItem.autoGenerated;
}

public MediaFormat getMediaFormat() {
Expand Down Expand Up @@ -270,6 +274,7 @@ public MediaFormat getMediaFormat() {
private boolean isDrc;
private long lastModified;
private String xtags;
private boolean autoGenerated;

public int getBitrate() {
return bitrate;
Expand Down Expand Up @@ -724,4 +729,23 @@ public String getXtags() {
public void setXtags(final String xtags) {
this.xtags = xtags;
}

/**
* Return whether the stream is auto-generated.
*
* @return {@code true} if the stream is auto-generated, {@code false} otherwise
*/
public boolean isAutoGenerated() {
return autoGenerated;
}


/**
* Set whether the stream has been auto-generated.
*
* @param autoGenerated whether the stream has been automatically generated
*/
public void setAutoGenerated(final boolean autoGenerated) {
this.autoGenerated = autoGenerated;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,9 @@ private ItagInfo buildAndAddItagInfoToList(
itagItem.setAudioTrackType(YoutubeParsingHelper.extractAudioTrackType(streamUrl));
}

itagItem.setAudioTrackName(formatData.getObject("audioTrack")
.getString("displayName"));
final JsonObject audioTrack = formatData.getObject("audioTrack");
itagItem.setAudioTrackName(audioTrack.getString("displayName"));
itagItem.setAutoGenerated(audioTrack.getBoolean("isAutoDubbed", false));
}

// YouTube return the content length and the approximate duration as strings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,24 @@ void testCheckDescriptiveAudio() throws Exception {
.anyMatch(s -> s.getAudioTrackType() == AudioTrackType.DESCRIPTIVE));
}
}

public static class AutoGeneratedAudio extends DefaultSimpleExtractorTest<StreamExtractor>
implements InitYoutubeTest {
private static final String ID = "3JW3J4_Ukrs";
private static final String URL = BASE_URL + ID;

@Override
protected StreamExtractor createExtractor() throws Exception {
return YouTube.getStreamExtractor(URL);
}

@Test
void testAutogeneratedTracks() throws Exception {
assertFalse(extractor().getAudioStreams().isEmpty());

assertTrue(extractor().getAudioStreams()
.stream()
.anyMatch(s -> s.getItagItem().isAutoGenerated()));
}
}
}
Loading