Skip to content

Commit

Permalink
Merge pull request #850 from glouel/master
Browse files Browse the repository at this point in the history
tvos13 videos🎉
  • Loading branch information
glouel authored Sep 25, 2019
2 parents ed1f888 + bc25914 commit 5e71bba
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 32 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1183,15 +1183,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta12;
CURRENT_PROJECT_VERSION = 1.5.1beta13;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.5.1beta12;
MARKETING_VERSION = 1.5.1beta13;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1212,15 +1212,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta12;
CURRENT_PROJECT_VERSION = 1.5.1beta13;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.5.1beta12;
MARKETING_VERSION = 1.5.1beta13;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

// To workaround our High Sierra issues with textfields, we have separate panels
// that replicate the features and are editable. They are hidden unless needed.
if #available(OSX 10.16, *) {
if #available(OSX 10.14, *) {
editMarginButton.isHidden = true
editExtraMessageButton.isHidden = true
enterCoordinatesButton.isHidden = true
Expand Down
30 changes: 28 additions & 2 deletions Aerial/Source/Models/AerialVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import AVFoundation

enum Manifests: String {
case tvOS10 = "tvos10.json", tvOS11 = "tvos11.json", tvOS12 = "entries.json", customVideos = "customvideos.json"
case tvOS10 = "tvos10.json", tvOS11 = "tvos11.json", tvOS12 = "tvos12.json", tvOS13 = "tvos13.json", customVideos = "customvideos.json"
}

private let spaceVideos = [
Expand All @@ -36,6 +36,25 @@ private let spaceVideos = [
"03EC0F5E-CCA8-4E0A-9FEC-5BD1CE151182", // 25/01 Antartica Aurora
"737E9E24-49BE-4104-9B72-F352DE1AD2BF", // North America Aurora
"E556BBC5-D0A0-4DB1-AC77-BC76E4A526F4", // Sahara and Italy
"64D11DAB-3B57-4F14-AD2F-E59A9282FA44", // Atlantic Ocean to Spain and France
"81337355-E156-4242-AAF4-711768D30A54", // Australia
"1088217C-1410-4CF7-BDE9-8F573A4DBCD9", // Caribbean
"3C4678E4-4D3D-4A40-8817-77752AEA62EB", // Nile Delta
"87060EC2-D006-4102-98CC-3005C68BB343", // South Africa to North Asia

]

private let seaVideos = [
"83C65C90-270C-4490-9C69-F51FE03D7F06", // Seals
"BA4ECA11-592F-4727-9221-D2A32A16EB28", // Palau Jellies
"F07CC61B-30FC-4614-BDAD-3240B61F6793", // Palau Coral
"6143116D-03BB-485E-864E-A8CF58ACF6F1", // Kelp
"2B30E324-E4FF-4CC1-BA45-A958C2D2B2EC", // Barracuda
"E580E5A5-0888-4BE8-A4CA-F74A18A643C3", // Palau Jellies
"EC3DC957-D4C2-4732-AACE-7D0C0F390EC8", // Palau Jellies
"581A4F1A-2B6D-468C-A1BE-6F473F06D10B", // Sea Stars
"687D03A2-18A5-4181-8E85-38F3A13409B9", // Bumpheads
"537A4DAB-83B0-4B66-BCD1-05E5DBB4A268", // Jacks
]

private let timeInformation = [
Expand Down Expand Up @@ -189,7 +208,14 @@ final class AerialVideo: CustomStringConvertible, Equatable {
self.id = id

// We override names for known space videos
if spaceVideos.contains(id) {
if seaVideos.contains(id) {
self.name = "Sea"
if secondaryName != "" {
self.secondaryName = secondaryName
} else {
self.secondaryName = name
}
} else if spaceVideos.contains(id) {
self.name = "Space"
if secondaryName != "" {
self.secondaryName = secondaryName
Expand Down
47 changes: 47 additions & 0 deletions Aerial/Source/Models/Downloads/DownloadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,53 @@ extension DownloadOperation: URLSessionTaskDelegate {
process.launch()

process.waitUntilExit()

let fileManager = FileManager.default
let src = VideoCache.appSupportDirectory!.appending("/entries.json")
let dest = VideoCache.appSupportDirectory!.appending("/tvos12.json")

do {
try fileManager.moveItem(atPath: src, toPath: dest)
} catch let error as NSError {
debugLog("Error renaming tvos12.json: \(error)")
}

let bsrc = VideoCache.appSupportDirectory!.appending("/TVIdleScreenStrings.bundle")
let bdest = VideoCache.appSupportDirectory!.appending("/TVIdleScreenStrings12.bundle")

do {
try fileManager.moveItem(atPath: bsrc, toPath: bdest)
} catch let error as NSError {
debugLog("Error renaming TVIdleScreenStrings12.bundle: \(error)")
}

} else if task.originalRequest!.url!.absoluteString.contains("resources-13.tar") {
debugLog("untaring resources-13.tar")

// Extract json
let process: Process = Process()
let cacheDirectory = VideoCache.appSupportDirectory!

var cacheResourcesString = cacheDirectory
cacheResourcesString.append(contentsOf: "/resources-13.tar")

process.currentDirectoryPath = cacheDirectory
process.launchPath = "/usr/bin/tar"
process.arguments = ["-xvf", cacheResourcesString]

process.launch()

process.waitUntilExit()

let fileManager = FileManager.default
let src = VideoCache.appSupportDirectory!.appending("/entries.json")
let dest = VideoCache.appSupportDirectory!.appending("/tvos13.json")

do {
try fileManager.moveItem(atPath: src, toPath: dest)
} catch let error as NSError {
debugLog("Error renaming tvos13.json: \(error)")
}
}

debugLog("Finished downloading \(task.originalRequest!.url!.absoluteString)")
Expand Down
50 changes: 39 additions & 11 deletions Aerial/Source/Models/ManifestLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ManifestLoader {
var manifestTvOS10: Data?
var manifestTvOS11: Data?
var manifestTvOS12: Data?
var manifestTvOS13: Data?

// Playlist management
var playlistIsRestricted = false
Expand Down Expand Up @@ -284,6 +285,7 @@ class ManifestLoader {
debugLog("isManifestCached 10 \(isManifestCached(manifest: .tvOS10))")
debugLog("isManifestCached 11 \(isManifestCached(manifest: .tvOS11))")
debugLog("isManifestCached 12 \(isManifestCached(manifest: .tvOS12))")
debugLog("isManifestCached 12 \(isManifestCached(manifest: .tvOS13))")

This comment has been minimized.

Copy link
@Quentame

Quentame Sep 25, 2019

Should it be « isManifestCached 13 » ?

This comment has been minimized.

Copy link
@glouel

glouel Sep 25, 2019

Author Collaborator

Well spotted ! It's just the debug info, but fixing, thanks !


checkIfShouldRedownloadFiles()

Expand All @@ -308,7 +310,11 @@ class ManifestLoader {

var urls: [URL] = []

// For tvOS12, json is now in a tar file
// For tvOS12-13, json is now in a tar file
if !isManifestCached(manifest: .tvOS13) {
urls.append(URL(string: "https://sylvan.apple.com/Aerials/resources-13.tar")!)
}

if !isManifestCached(manifest: .tvOS12) {
urls.append(URL(string: "https://sylvan.apple.com/Aerials/resources.tar")!)
}
Expand Down Expand Up @@ -354,6 +360,10 @@ class ManifestLoader {
var urls: [URL] = []

// For tvOS12, json is now in a tar file
if !isManifestCached(manifest: .tvOS13) {
urls.append(URL(string: "https://sylvan.apple.com/Aerials/resources-13.tar")!)
}

if !isManifestCached(manifest: .tvOS12) {
urls.append(URL(string: "https://sylvan.apple.com/Aerials/resources.tar")!)
}
Expand Down Expand Up @@ -502,6 +512,7 @@ class ManifestLoader {
}
}

// tvOS < 12 sta
func moveOldManifests() {
debugLog("move")
let cacheDirectory = VideoCache.appSupportDirectory!
Expand All @@ -513,9 +524,9 @@ class ManifestLoader {
let today = dateFormatter.string(from: current)

cacheResourcesString.append(contentsOf: "/backups/"+today)
let previous = URL(fileURLWithPath: cacheDirectory.appending("/entries.json"))
if FileManager.default.fileExists(atPath: cacheDirectory.appending("/entries.json")) {
let new = URL(fileURLWithPath: cacheResourcesString.appending("/entries.json"))
let previous = URL(fileURLWithPath: cacheDirectory.appending("/tvos12.json"))
if FileManager.default.fileExists(atPath: cacheDirectory.appending("/tvos12.json")) {
let new = URL(fileURLWithPath: cacheResourcesString.appending("/tvos12.json"))

let cacheUrl = URL(fileURLWithPath: cacheResourcesString)
if #available(OSX 10.11, *) {
Expand All @@ -525,7 +536,7 @@ class ManifestLoader {
debugLog("creating dir \(cacheResourcesString)")

try FileManager.default.moveItem(at: previous, to: new)
debugLog("moving entries.json")
debugLog("moving tvos12.json")
} catch {
errorLog("\(error.localizedDescription)")
}
Expand All @@ -538,7 +549,7 @@ class ManifestLoader {

// Check if the Manifests have been loaded in this class already
func areManifestsFilesLoaded() -> Bool {
if manifestTvOS12 != nil && manifestTvOS11 != nil && manifestTvOS10 != nil {
if manifestTvOS13 != nil && manifestTvOS12 != nil && manifestTvOS11 != nil && manifestTvOS10 != nil {
debugLog("Manifests files were loaded in class")
return true
} else {
Expand All @@ -549,7 +560,7 @@ class ManifestLoader {

// Check if the Manifests are saved in our cache directory
func areManifestsCached() -> Bool {
return isManifestCached(manifest: .tvOS10) && isManifestCached(manifest: .tvOS11) && isManifestCached(manifest: .tvOS12)
return isManifestCached(manifest: .tvOS10) && isManifestCached(manifest: .tvOS11) && isManifestCached(manifest: .tvOS12) && isManifestCached(manifest: .tvOS13)
}

// Check if a Manifest is saved in our cache directory
Expand All @@ -573,14 +584,24 @@ class ManifestLoader {
// Load the JSON Data cached on disk
func loadCachedManifests() {
if let cacheDirectory = VideoCache.appSupportDirectory {
// tvOS12
// tvOS13
var cacheFileUrl = URL(fileURLWithPath: cacheDirectory as String)
cacheFileUrl.appendPathComponent("entries.json")
cacheFileUrl.appendPathComponent("tvos13.json")
do {
let ndata = try Data(contentsOf: cacheFileUrl)
manifestTvOS13 = ndata
} catch {
errorLog("Can't load tvos13.json from cached directory (tvOS12)")
}

// tvOS12
cacheFileUrl = URL(fileURLWithPath: cacheDirectory as String)
cacheFileUrl.appendPathComponent("tvos12.json")
do {
let ndata = try Data(contentsOf: cacheFileUrl)
manifestTvOS12 = ndata
} catch {
errorLog("Can't load entries.json from cached directory (tvOS12)")
errorLog("Can't load tvos12.json from cached directory (tvOS12)")
}

// tvOS11
Expand All @@ -603,7 +624,7 @@ class ManifestLoader {
errorLog("Can't load tvos10.json from cached directory")
}

if manifestTvOS10 != nil || manifestTvOS11 != nil || manifestTvOS12 != nil {
if manifestTvOS10 != nil || manifestTvOS11 != nil || manifestTvOS12 != nil || manifestTvOS13 != nil {
loadManifestsFromLoadedFiles()
} else {
// No internet, no anything, nothing to do
Expand All @@ -617,6 +638,13 @@ class ManifestLoader {
// Reset our array
processedVideos = []

if manifestTvOS12 != nil {
// We start with the more recent one, it has more information (poi, etc)
readJSONFromData(manifestTvOS13!, manifest: .tvOS13)
} else {
warnLog("tvOS13 manifest is absent")
}

if manifestTvOS12 != nil {
// We start with the more recent one, it has more information (poi, etc)
readJSONFromData(manifestTvOS12!, manifest: .tvOS12)
Expand Down
Loading

0 comments on commit 5e71bba

Please sign in to comment.