1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2026-04-19 05:11:22 +00:00

Made youtu.be links be vieweble through NewPipe, and fixed InfoBar design.

This commit is contained in:
Christian Schabesberger
2015-09-10 20:42:39 +02:00
parent e38f90757a
commit fde0b2ae7f
7 changed files with 69 additions and 13 deletions

View File

@@ -120,7 +120,7 @@ public class PlayVideoActivity extends AppCompatActivity {
}
}
});
hideUi();
showUi();
}
@Override

View File

@@ -120,7 +120,7 @@ public class VideoListAdapter extends BaseAdapter {
holder.itemDurationView.setText(videoList.get(position).duration);
if(listView.isItemChecked(position)) {
convertView.setBackgroundColor(context.getResources().getColor(R.color.actionBarColorYoutube));
convertView.setBackgroundColor(context.getResources().getColor(R.color.primaryColorYoutube));
} else {
convertView.setBackgroundColor(0);
}

View File

@@ -95,19 +95,32 @@ public class YoutubeExtractor implements Extractor {
@Override
public String getVideoId(String videoUrl) {
try {
String query = (new URI(videoUrl)).getQuery();
String queryElements[] = query.split("&");
Map<String, String> queryArguments = new HashMap<>();
for(String e : queryElements) {
String[] s = e.split("=");
queryArguments.put(s[0], s[1]);
URI uri = new URI(videoUrl);
if(uri.getHost().contains("youtube")) {
String query = uri.getQuery();
String queryElements[] = query.split("&");
Map<String, String> queryArguments = new HashMap<>();
for (String e : queryElements) {
String[] s = e.split("=");
queryArguments.put(s[0], s[1]);
}
return queryArguments.get("v");
} else if(uri.getHost().contains("youtu.be")) {
// uri.getRawPath() does somehow not return the last character.
// so we do a workaround instead.
//return uri.getRawPath();
String url[] = videoUrl.split("/");
return url[url.length-1];
} else {
Log.e(TAG, "Error could not parse url: " + videoUrl);
}
return queryArguments.get("v");
} catch(Exception e) {
} catch(Exception e) {
Log.e(TAG, "Error could not parse url: " + videoUrl);
e.printStackTrace();
return "";
}
return null;
}
@Override