From fde0b2ae7fb2fdbe91063e28ffc0d33610253d63 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 10 Sep 2015 20:42:39 +0200 Subject: [PATCH] Made youtu.be links be vieweble through NewPipe, and fixed InfoBar design. --- app/src/main/AndroidManifest.xml | 8 +++++ .../org/schabi/newpipe/PlayVideoActivity.java | 2 +- .../org/schabi/newpipe/VideoListAdapter.java | 2 +- .../newpipe/youtube/YoutubeExtractor.java | 29 ++++++++++++----- app/src/main/res/values-v21/styles.xml | 32 +++++++++++++++++++ app/src/main/res/values/colors.xml | 3 +- app/src/main/res/values/styles.xml | 6 ++-- 7 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/values-v21/styles.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 215fb3050..27fdfdc7a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -55,6 +55,14 @@ android:host="m.youtube.com" android:scheme="https" android:pathPrefix="/watch"/> + + 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 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 diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml new file mode 100644 index 000000000..e0b443174 --- /dev/null +++ b/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ff356914a..eaf1f6c18 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,5 +1,6 @@ - #dd0000 + #dd0000 + #bb0000 #66000000 \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4e752773a..454286d7f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -4,13 +4,15 @@