Skip to content

Commit

Permalink
Merge pull request #72 from shinovon/some
Browse files Browse the repository at this point in the history
2.5.2
  • Loading branch information
shinovon authored Sep 12, 2023
2 parents fe9a076 + a9b6c51 commit 1312480
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 336 deletions.
2 changes: 1 addition & 1 deletion Application Descriptor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Nokia-MIDlet-Background-Event: pause
MIDlet-Version: 2.5.1
MIDlet-Version: 2.5.2
MIDlet-Info-URL: http://nnp.nnchan.ru/jtube
Nokia-MIDlet-S60-Selection-Key-Compatibility: true
MicroEdition-Configuration: CLDC-1.0
Expand Down
76 changes: 43 additions & 33 deletions src/jtube/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ of this software and associated documentation files (the "Software"), to deal
import cc.nnproject.json.JSONArray;
import cc.nnproject.json.JSONException;
import cc.nnproject.json.JSONObject;
import cc.nnproject.utils.PlatformUtils;
import cc.nnproject.ytapp.App2;
import jtube.ui.AppUI;
import jtube.ui.Locale;
Expand Down Expand Up @@ -364,17 +363,25 @@ static JSONObject getVideoInfo(String id, String res) throws JSONException, IOEx
public static String getVideoLink(String id, String res, boolean forceProxy) throws JSONException, IOException {
JSONObject o = getVideoInfo(id, res);
if(o == null) throw new RuntimeException("not found");
String s = o.getString("url");
String url = o.getString("url");
if(Settings.httpStream || forceProxy) {
if(Settings.playbackProxy) {
int i = s.indexOf("/videoplayback");
s = Settings.videoplaybackProxy + s.substring(i+14);
}
if(!Settings.playbackProxy || Settings.useApiProxy) {
s = Settings.serverstream + Util.url(s);
switch(Settings.playbackProxyVariant) {
case 0:
url = Settings.inv + url.substring(url.indexOf("/videoplayback")+1);
if(Settings.useApiProxy) { // TODO?
url = Settings.serverstream + Util.url(url);
}
break;
case 1:
url = Settings.videoplaybackProxy + url.substring(url.indexOf("/videoplayback")+14);
break;
case 2:
url = Settings.serverstream + Util.url(url);
break;
}
}
return s;
System.out.println(url);
return url;
}

public static String getVideoLink(String id, String res) throws JSONException, IOException {
Expand Down Expand Up @@ -417,11 +424,11 @@ public void commandAction(Command c, Displayable arg1) {
return;
}
String url = getVideoLink(id, Settings.videoRes, true);
boolean bada = PlatformUtils.isBada();
String file = bada ? System.getProperty("fileconn.dir.videos") : ("file:///" + Settings.downloadDir);
boolean bada = PlatformUtils.isBada;
String file = bada ? "file:///Media/Videos/" : ("file:///" + Settings.downloadDir);
if (!file.endsWith("/") && !file.endsWith("\\"))
file += "/";
if (PlatformUtils.isSymbian3Based() || PlatformUtils.isBada()) {
if (PlatformUtils.isSymbian3Based() || PlatformUtils.isBada) {
file += "watch.ram";
} else /*if (PlatformUtils.isSymbian93()) {
file += "watch.ram";
Expand All @@ -433,9 +440,20 @@ public void commandAction(Command c, Displayable arg1) {
FileConnection fc = null;
OutputStream o = null;
try {
fc = (FileConnection) Connector.open(file, 3);
if (fc.exists())
fc.delete();
try {
fc = (FileConnection) Connector.open(file, 3);
if (fc.exists())
fc.delete();
} catch (IOException e) {
if(!bada) throw e;
file = System.getProperty("fileconn.dir.videos");
if (!file.endsWith("/") && !file.endsWith("\\"))
file += "/";
file += "watch.ram";
fc = (FileConnection) Connector.open(file, 3);
if (fc.exists())
fc.delete();
}
fc.create();
o = fc.openDataOutputStream();
o.write(url.getBytes("UTF-8"));
Expand Down Expand Up @@ -593,8 +611,7 @@ public static boolean parseStartArguments() {
String s;
if((s = (String) args.get("url")) != null && s.length() > 0) {
try {
s = Util.decodeURL(s);
openURL(s);
openURL(Util.decodeURL(s));
return true;
} catch (IllegalArgumentException e) {
return false;
Expand All @@ -616,18 +633,17 @@ public static void openURL(String url) {
if(inst == null || inst.ui == null) {
return;
}
final String https = "https://";
final String http = "http://";
final String www = "www.";
if(url.startsWith(https)) url = url.substring(https.length());
else if(url.startsWith(http)) url = url.substring(http.length());
if(url.startsWith(www)) url = url.substring(www.length());
if(url.startsWith("https")) url = url.substring(5);
else if(url.startsWith("http")) url = url.substring(4);
if(url.startsWith("://")) url = url.substring(3);
if(url.startsWith("www")) url = url.substring(3);
if(url.startsWith("m.")) url = url.substring(2);
if(url.startsWith("youtu.be")) {
int i = url.indexOf('/');
if(i == -1)
throw new IllegalArgumentException();
url = url.substring(i + 1);
if((i = url.indexOf('/')) != -1) {
if((i = url.indexOf('/')) != -1 || (i = url.indexOf('?')) != -1) {
url = url.substring(0, i);
}
inst.ui.openVideo(url);
Expand All @@ -652,17 +668,13 @@ public static void openURL(String url) {
if(i == -1)
throw new IllegalArgumentException();
url = url.substring(i + 1);
if((i = url.indexOf('/')) != -1) {
url = url.substring(0, i);
} else if((i = url.indexOf('?')) != -1) {
if((i = url.indexOf('/')) != -1 || (i = url.indexOf('?')) != -1) {
url = url.substring(0, i);
}
inst.ui.openVideo(url);
} else if(url.startsWith("@")) {
url = url.substring(url.indexOf('@'));
if((i = url.indexOf('/')) != -1) {
url = url.substring(0, i);
} else if((i = url.indexOf('?')) != -1) {
if((i = url.indexOf('/')) != -1 || (i = url.indexOf('?')) != -1) {
url = url.substring(0, i);
}
inst.ui.openChannel(url);
Expand All @@ -671,9 +683,7 @@ public static void openURL(String url) {
if(i == -1)
throw new IllegalArgumentException();
url = url.substring(i + 1);
if((i = url.indexOf('/')) != -1) {
url = url.substring(0, i);
} else if((i = url.indexOf('?')) != -1) {
if((i = url.indexOf('/')) != -1 || (i = url.indexOf('?')) != -1) {
url = url.substring(0, i);
}
inst.ui.openChannel(url);
Expand Down
16 changes: 12 additions & 4 deletions src/jtube/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,19 @@ public void run() {
JSONObject o = App.getVideoInfo(id, res);
String url = o.getString("url");
if(Settings.httpStream) {
if(Settings.playbackProxy) {
int i = url.indexOf("/videoplayback");
url = Settings.videoplaybackProxy + url.substring(i+14);
} else {
switch(Settings.playbackProxyVariant) {
case 0:
url = Settings.inv + url.substring(url.indexOf("/videoplayback")+1);
if(Settings.useApiProxy) {
url = Settings.serverstream + Util.url(url);
}
break;
case 1:
url = Settings.videoplaybackProxy + url.substring(url.indexOf("/videoplayback")+14);
break;
case 2:
url = Settings.serverstream + Util.url(url);
break;
}
}
int contentLength = o.getInt("clen", 0);
Expand Down
Loading

0 comments on commit 1312480

Please sign in to comment.