Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 4k videos + error handling for invalid video source #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion ScreenSaver/AerialEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ public static List<Asset> GetMovies()
}
public static List<Asset> GetAllMovies()
{
//if no Entries, just return an empty list
if (GetAllEntries() == null) { return new List<Asset>(); }

return GetAllEntries().SelectMany(s => s.assets).ToList();
}

private static List<Asset> FilterEntries(IdAsset[] urls)
{
if (urls == null) { return new List<Asset>(); }; //if no URLS, return an empty list

var time = (DateTime.Now.Hour < 6 || DateTime.Now.Hour > 19) ? "night" : "day";
var ran = new Random();
var settings = new RegSettings();
Expand Down Expand Up @@ -71,7 +76,17 @@ public static IdAsset[] GetAllEntries()
WebClient webClient = new WebClient();
entries = webClient.DownloadString(aerialUrl);
}
cachedEntities = new JavaScriptSerializer().Deserialize<IdAsset[]>(entries);

try
{
cachedEntities = new JavaScriptSerializer().Deserialize<IdAsset[]>(entries);
}
catch (ArgumentException e)
{
//the passed in entities document is invalid.
return null;
}


return cachedEntities;
}
Expand Down
4 changes: 4 additions & 0 deletions ScreenSaver/AerialGlobalVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ static class AerialGlobalVars
public static string githubAllReleases = "https://github.com/cDima/Aerial/releases";
//link to the apple videos
public static string appleVideosURI = "http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/entries.json";
//link to the 4k apple videos (hosted by Jonathon Powell)
public static string applefourKVideoURI = "https://t27q97zg19.execute-api.us-east-1.amazonaws.com/prod/aerialAltJSON/4kEntites.json";
//original link to 4k apple videos, we can't parse this currently so I hosted a modified version
//public static string applefourKVideoURI = "https://sylvan.apple.com/Aerials/2x/entries.json";
}
}
11 changes: 11 additions & 0 deletions ScreenSaver/ScreenSaverForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,17 @@ private void SetNextVideo()
var cacheEnabled = new RegSettings().CacheVideos;
if (showVideo)
{
//If movies is null, when we tried to parse the JSON doc with the movies it
//failed or it was empty.
if (Movies == null || Movies.Count == 0)
{
showVideo = false;
MessageBox.Show("Error finding the video locations. Please confirm that the video source " +
"is a valid JSON document and can be reached. Resart after fixing the video source");

return;
}

string url = Movies[currentVideoIndex].url;

if (Caching.IsHit(url))
Expand Down
Loading