Skip to content

Commit

Permalink
FIX: [droid] revert to http for file url's
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Jan 26, 2018
1 parent 2e8220f commit 7898d2d
Showing 1 changed file with 47 additions and 35 deletions.
82 changes: 47 additions & 35 deletions tools/android/packaging/xbmc/src/XBMCJsonRPC.java.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package @APP_PACKAGE@;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.ArrayList;

Expand Down Expand Up @@ -214,7 +212,21 @@ public class XBMCJsonRPC

public String getDownloadUrl(String src)
{
return src;
try
{
String returl = Uri.parse(m_xbmc_web_url)
.buildUpon()
.appendPath("vfs")
.appendPath(src)
.build()
.toString();
return returl;
}
catch (Exception e)
{
e.printStackTrace();
return "";
}
}

public boolean Ping()
Expand Down Expand Up @@ -406,8 +418,8 @@ public class XBMCJsonRPC
movie.get("movieid").getAsString(),
movie.get("title").getAsString(),
movie.get("tagline").getAsString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(movie.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(movie.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(movie.get("thumbnail").getAsString()).toString(),
XBMCFileContentProvider.buildUri(movie.get("thumbnail").getAsString()).toString(),
Intent.ACTION_GET_CONTENT,
Uri.parse("videodb://movies/titles/" + movie.get("movieid").getAsString() + "?showinfo=true"),
0,
Expand Down Expand Up @@ -454,8 +466,8 @@ public class XBMCJsonRPC
tvshow.get("tvshowid").getAsString(),
tvshow.get("title").getAsString(),
tvshow.get("plot").getAsString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(tvshow.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(tvshow.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(tvshow.get("thumbnail").getAsString()).toString(),
XBMCFileContentProvider.buildUri(tvshow.get("thumbnail").getAsString()).toString(),
Intent.ACTION_GET_CONTENT,
Uri.parse("videodb://tvshows/titles/" + tvshow.get("tvshowid").getAsString() + "?showinfo=true"),
0,
Expand Down Expand Up @@ -492,8 +504,8 @@ public class XBMCJsonRPC
album.get("albumid").getAsString(),
album.get("title").getAsString(),
album.get("displayartist").getAsString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(album.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(album.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(album.get("thumbnail").getAsString()).toString(),
XBMCFileContentProvider.buildUri(album.get("thumbnail").getAsString()).toString(),
Intent.ACTION_GET_CONTENT,
Uri.parse("musicdb://albums/" + album.get("albumid").getAsString() + "/"),
0,
Expand Down Expand Up @@ -528,8 +540,8 @@ public class XBMCJsonRPC
artist.get("artistid").getAsString(),
artist.get("artist").getAsString(),
artist.get("description").getAsString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(artist.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(getDownloadUrl(artist.get("thumbnail").getAsString())).toString(),
XBMCFileContentProvider.buildUri(artist.get("thumbnail").getAsString()).toString(),
XBMCFileContentProvider.buildUri(artist.get("thumbnail").getAsString()).toString(),
Intent.ACTION_GET_CONTENT,
Uri.parse("musicdb://artists/" + artist.get("artistid").getAsString() + "/"),
0,
Expand Down Expand Up @@ -586,7 +598,7 @@ public class XBMCJsonRPC

if (movie.has("fanart") && !movie.get("fanart").getAsString().isEmpty())
notificationBuilder.setBackground(XBMCFileContentProvider.buildUri(
getDownloadUrl(movie.get("fanart").getAsString())).toString());
movie.get("fanart").getAsString()).toString());
if (movie.has("thumbnail") && !movie.get("thumbnail").getAsString().isEmpty())
{
Bitmap bitmap = getBitmap(ctx, movie.get("thumbnail").getAsString());
Expand Down Expand Up @@ -633,7 +645,7 @@ public class XBMCJsonRPC

if (tvshow.has("fanart") && !tvshow.get("fanart").getAsString().isEmpty())
notificationBuilder.setBackground(XBMCFileContentProvider.buildUri(
getDownloadUrl(tvshow.get("fanart").getAsString())).toString());
tvshow.get("fanart").getAsString()).toString());
if (tvshow.has("thumbnail") && !tvshow.get("thumbnail").getAsString().isEmpty())
{
Bitmap bitmap = getBitmap(ctx, tvshow.get("thumbnail").getAsString());
Expand Down Expand Up @@ -681,7 +693,7 @@ public class XBMCJsonRPC

if (album.has("fanart") && !album.get("fanart").getAsString().isEmpty())
notificationBuilder.setBackground(XBMCFileContentProvider.buildUri(
getDownloadUrl(album.get("fanart").getAsString())).toString());
album.get("fanart").getAsString()).toString());
if (album.has("thumbnail") && !album.get("thumbnail").getAsString().isEmpty())
{
Bitmap bitmap = getBitmap(ctx, album.get("thumbnail").getAsString());
Expand Down Expand Up @@ -770,7 +782,7 @@ public class XBMCJsonRPC

JsonObject fileO = results.get("filedetails").getAsJsonObject();
Uri uri = Uri.parse(fileO.get("file").getAsString());
f = File.createFile(fileO.get("label").getAsString(), "file", XBMCFileContentProvider.buildUri(uri.toString()).toString(), fileO.get("size").getAsLong());
f = File.createFile(fileO.get("label").getAsString(), "file", XBMCFileContentProvider.buildUri(uri.toString()).toString());
}
catch (Exception e)
{
Expand Down Expand Up @@ -801,7 +813,7 @@ public class XBMCJsonRPC
{
JsonObject fileO = filesA.get(i).getAsJsonObject();
Uri uri = Uri.parse(fileO.get("file").getAsString());
File file = File.createFile(fileO.get("label").getAsString(), fileO.get("filetype").getAsString(), XBMCFileContentProvider.buildUri(uri.toString()).toString(), 0);
File file = File.createFile(fileO.get("label").getAsString(), fileO.get("filetype").getAsString(), XBMCFileContentProvider.buildUri(uri.toString()).toString());
if (fileO.has("id"))
file.setId(fileO.get("id").getAsInt());
if (fileO.has("type") && !fileO.get("type").getAsString().equals("unknown"))
Expand All @@ -827,14 +839,14 @@ public class XBMCJsonRPC
med.setDescription(details.get("tagline").getAsString());
if (details.has("thumbnail") && !details.get("thumbnail").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("thumbnail").getAsString());
String url = details.get("thumbnail").getAsString();
if (url != null && url != null && !url.isEmpty())
med.setCardImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
med.setCardImageAspectRatio("2:3");
if (details.has("fanart") && !details.get("fanart").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("fanart").getAsString());
String url = details.get("fanart").getAsString();
if (url != null && url != null && !url.isEmpty())
med.setBackgroundImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
Expand Down Expand Up @@ -885,14 +897,14 @@ public class XBMCJsonRPC
med.setDescription(ja.get(0).getAsString());
if (details.has("thumbnail") && !details.get("thumbnail").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("thumbnail").getAsString());
String url = details.get("thumbnail").getAsString();
if (url != null && !url.isEmpty())
med.setCardImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
med.setCardImageAspectRatio("2:3");
if (details.has("fanart") && !details.get("fanart").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("fanart").getAsString());
String url = details.get("fanart").getAsString();
if (url != null && !url.isEmpty())
med.setBackgroundImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
Expand All @@ -918,23 +930,23 @@ public class XBMCJsonRPC
med.setDescription(details.get("showtitle").getAsString());
if (details.has("thumbnail") && !details.get("thumbnail").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("thumbnail").getAsString());
String url = details.get("thumbnail").getAsString();
if (url != null && !url.isEmpty())
med.setCardImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
med.setCardImageAspectRatio("16:9");
if (details.has("fanart") && !details.get("fanart").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("fanart").getAsString());
String url = details.get("fanart").getAsString();
if (url != null && !url.isEmpty())
med.setBackgroundImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
med.setXbmcUrl("videodb://tvshows/titles/" + details.get("tvshowid").getAsInt() + "/" + details.get("episodeid").getAsInt() + "?showinfo=true");
/*
String url = getDownloadUrl(details.get("file").getAsString());
if (!url.isEmpty())
med.setVideoUrl(url);
*/

String url = details.get("file").getAsString();
if (url != null && !url.isEmpty())
med.setVideoUrl(getDownloadUrl(url));

med.setCategory(Media.MEDIA_TYPE_TVEPISODE);

med.setSeason(details.get("season").getAsInt());
Expand All @@ -959,14 +971,14 @@ public class XBMCJsonRPC
med.setDescription(details.get("displayartist").getAsString());
if (details.has("thumbnail") && !details.get("thumbnail").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("thumbnail").getAsString());
String url = details.get("thumbnail").getAsString();
if (url != null && !url.isEmpty())
med.setCardImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
med.setCardImageAspectRatio("1:1");
if (details.has("fanart") && !details.get("fanart").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("fanart").getAsString());
String url = details.get("fanart").getAsString();
if (url != null && !url.isEmpty())
med.setBackgroundImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
Expand All @@ -992,14 +1004,14 @@ public class XBMCJsonRPC
med.setDescription(details.get("displayartist").getAsString());
if (details.has("thumbnail") && !details.get("thumbnail").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("thumbnail").getAsString());
String url = details.get("thumbnail").getAsString();
if (url != null && !url.isEmpty())
med.setCardImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
med.setCardImageAspectRatio("1:1");
if (details.has("fanart") && !details.get("fanart").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("fanart").getAsString());
String url = details.get("fanart").getAsString();
if (url != null && !url.isEmpty())
med.setBackgroundImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
Expand Down Expand Up @@ -1045,23 +1057,23 @@ public class XBMCJsonRPC
med.setDescription(ja.get(0).getAsString());
if (details.has("thumbnail") && !details.get("thumbnail").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("thumbnail").getAsString());
String url = details.get("thumbnail").getAsString();
if (url != null && !url.isEmpty())
med.setCardImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}
med.setCardImageAspectRatio("1:1");
if (details.has("fanart") && !details.get("fanart").getAsString().isEmpty())
{
String url = getDownloadUrl(details.get("fanart").getAsString());
String url = details.get("fanart").getAsString();
if (url != null && !url.isEmpty())
med.setBackgroundImageUrl(XBMCFileContentProvider.buildUri(url).toString());
}

med.setXbmcUrl("videodb://musicvideos/titles/" + details.get("musicvideoid").getAsInt());

String url = getDownloadUrl(details.get("file").getAsString());
String url = details.get("file").getAsString();
if (url != null && !url.isEmpty())
med.setVideoUrl(XBMCFileContentProvider.buildUri(url).toString());
med.setVideoUrl(getDownloadUrl(url));

med.setCategory(Media.MEDIA_TYPE_MUSICVIDEO);
}
Expand Down

0 comments on commit 7898d2d

Please sign in to comment.