Update ExtractorImpl.java

pull/466/head
okjack 2 years ago
parent 68e46835d4
commit 2e765b3675
  1. 5
      youtube/src/main/java/com/github/kiulian/downloader/extractor/ExtractorImpl.java

@ -42,7 +42,6 @@ public class ExtractorImpl implements Extractor {
@Override @Override
public JSONObject extractInitialDataFromHtml(String html) throws YoutubeException { public JSONObject extractInitialDataFromHtml(String html) throws YoutubeException {
String ytInitialData = null; String ytInitialData = null;
for (Pattern pattern : YT_INITIAL_DATA_PATTERNS) { for (Pattern pattern : YT_INITIAL_DATA_PATTERNS) {
Matcher matcher = pattern.matcher(html); Matcher matcher = pattern.matcher(html);
if (matcher.find()) { if (matcher.find()) {
@ -64,7 +63,6 @@ public class ExtractorImpl implements Extractor {
String ytPlayerConfig = null; String ytPlayerConfig = null;
for (Pattern pattern : YT_PLAYER_CONFIG_PATTERNS) { for (Pattern pattern : YT_PLAYER_CONFIG_PATTERNS) {
Matcher matcher = pattern.matcher(html); Matcher matcher = pattern.matcher(html);
if (matcher.find()) { if (matcher.find()) {
ytPlayerConfig = matcher.group(1); ytPlayerConfig = matcher.group(1);
break; break;
@ -73,7 +71,6 @@ public class ExtractorImpl implements Extractor {
if (ytPlayerConfig == null) { if (ytPlayerConfig == null) {
throw new YoutubeException.BadPageException("Could not find player config on web page"); throw new YoutubeException.BadPageException("Could not find player config on web page");
} }
try { try {
JSONObject config = JSON.parseObject(ytPlayerConfig); JSONObject config = JSON.parseObject(ytPlayerConfig);
if (config.containsKey("args")) { if (config.containsKey("args")) {
@ -89,11 +86,9 @@ public class ExtractorImpl implements Extractor {
@Override @Override
public List<String> extractSubtitlesLanguagesFromXml(String xml) throws YoutubeException { public List<String> extractSubtitlesLanguagesFromXml(String xml) throws YoutubeException {
Matcher matcher = SUBTITLES_LANG_CODE_PATTERN.matcher(xml); Matcher matcher = SUBTITLES_LANG_CODE_PATTERN.matcher(xml);
if (!matcher.find()) { if (!matcher.find()) {
throw new YoutubeException.BadPageException("Could not find any language code in subtitles xml"); throw new YoutubeException.BadPageException("Could not find any language code in subtitles xml");
} }
List<String> languages = new ArrayList<>(); List<String> languages = new ArrayList<>();
do { do {
String language = matcher.group(1); String language = matcher.group(1);

Loading…
Cancel
Save