jesperbakhandskemager / view-youtube-dislike Goto Github PK
View Code? Open in Web Editor NEWBring back Youtube Dislike for Android (View Only)
License: GNU General Public License v3.0
Bring back Youtube Dislike for Android (View Only)
License: GNU General Public License v3.0
App version: 1.1.0 (from F-Droid)
OS: Android 10
Device: Samsung Galaxy A31
I will do my best to answer further questions.
Hello,
I'm a hobby "plain" java developer. A few months ago I saw the app in the F-droid store and it sounded interesting, so I tried it out. Since then, I've been using the app to look how many dislikes some really bad videos had and sometimes to share them with friends.
One thing that is, in my opinion, still missing in the app is a field to show the title of the video in the dislikes view. So if you, for example, take a screenshot of the app to share it with friends, they can directly see what video is it about.
After a little bit of research I found out, that the API at youtube.com/oembed is able to return some information about the video, including the title. Using https://youtube.com/oembed?format=json&url=[URL of the youtube video here]
the data is returned as a JSON string.
The following code snippet in normal java demonstrates the use of this API:
public static String getYoutubeVideoTitle(String url)
throws InterruptedException, URISyntaxException, IOException, ParseException {
url = "https://youtube.com/oembed?format=json&url=" + url;
// Request
BodySubscriber<String> subscriber = BodySubscribers.ofString(Charset.defaultCharset());
HttpRequest request = HttpRequest.newBuilder(new URI(url)).GET().build();
HttpClient client = HttpClient.newHttpClient();
String response = client.send(request, (responeInfo) -> subscriber).body();
// JSON parsing
JSONObject json = (JSONObject) new JSONParser().parse(new StringReader(response));
response = (String) json.get("title");
return response;
}
Since I'm not a android developer and my computer is to old to run android studio, I can't test this on android, but it tested it on my computer using the json-simple library and it worked as expected (Both youtube.com and youtu.be URLs).
To port it to android, my best guess is to change the request part to StringRequest, as used in app/src/main/java/com/jesperh/showyoutubedislikes/DisplayMessageActivity.java, line 126 and to parse the JSON using builtin android functions.
Thanks for making this app!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.