Browse Source

offline

master
schmicma 4 years ago
parent
commit
8caca22864
  1. 0
      download.js
  2. 18
      kplayer.xcodeproj/project.pbxproj
  3. 14
      kplayer/AppDelegate.swift
  4. 1
      kplayer/core/HtmlParser.swift
  5. 8
      kplayer/core/NetworkManager.swift
  6. 3
      kplayer/detail/BrowserController.swift
  7. 0
      links.html

0
kplayer/server/download.js → download.js

18
kplayer.xcodeproj/project.pbxproj

@ -18,7 +18,6 @@
1C736503B656C999E5E12081 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7365B06FA66294E99AC2D3 /* NetworkManager.swift */; };
1C73654C9EA6D255CFC039C5 /* NetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73620D01687FB4F1811C5C /* NetworkHelper.swift */; };
1C7365885FAF292F2221ED44 /* PhotoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73673DC671535E3A049F54 /* PhotoController.swift */; };
1C736662E43C6E8FFED11AC4 /* download.js in Sources */ = {isa = PBXBuildFile; fileRef = 1C736C1368E0DE89BAA2DF60 /* download.js */; };
1C7366A0CFD2B55BF8C3BAF0 /* NetworkDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7364F10BED5DA0F1C0423C /* NetworkDelegate.swift */; };
1C7366DAC06047DE335EFC37 /* BMPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736927EA28AFBEB25D7487 /* BMPlayer.swift */; };
1C73671FC2CCCACAA2FFC153 /* ThumbnailCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736EA15A11AF7D57F85824 /* ThumbnailCache.swift */; };
@ -33,11 +32,11 @@
1C73691A9C7174E0C6B57267 /* stringutil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736B794396F2E50387B8F2 /* stringutil.swift */; };
1C73693A1334A7792856FC58 /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73611D226B48C24DB37535 /* MasterViewController.swift */; };
1C736953BDBBAFC40884132A /* BrowserController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73602350ACE2436736F981 /* BrowserController.swift */; };
1C73696E4C0353053BF98031 /* links.html in Resources */ = {isa = PBXBuildFile; fileRef = 1C73615FFA2AA98BD1C56CD4 /* links.html */; };
1C7369ABC44CFB530EA71FB6 /* HeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736D9BB5498E7E8F11C754 /* HeaderCell.swift */; };
1C736A06A2AD75B8C14EEBBE /* HtmlParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736DBB6986A8B62963FBB3 /* HtmlParser.swift */; };
1C736A5FA5BA53B2597F2ED7 /* Kirschkeks-256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C736059262A57AADE6AB761 /* Kirschkeks-256x256.png */; };
1C736A7B6221A1D50FB3904C /* ItemType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73631C96E6C860833052CA /* ItemType.swift */; };
1C736B8E71B9D4A285F96AF3 /* links.html in Resources */ = {isa = PBXBuildFile; fileRef = 1C736BAAC83151BCA0271E83 /* links.html */; };
1C736CB96577F6A9A7BA03E8 /* BMPlayerItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7364F924BD979294C3EE4A /* BMPlayerItem.swift */; };
1C736CD0E54786D3A2405E51 /* BMPlayerLayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7366D766CDE0C9872E86F5 /* BMPlayerLayerView.swift */; };
1C736D16E81BA1FB325200E0 /* HanekeFetchOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7360744ABACC3557D05760 /* HanekeFetchOperation.swift */; };
@ -45,12 +44,14 @@
1C736D24B49451141CD4B64D /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7369F53095B7A4D65679C2 /* DetailViewController.swift */; };
1C736D895B75BDCDB35937C1 /* BMTimeSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7360AE55EB115762C42EB9 /* BMTimeSlider.swift */; };
1C736DB41BD06D359E6A0DEE /* BMSubtitles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7366AAB82A46086690E164 /* BMSubtitles.swift */; };
1C736E1B0A79D5925BF7BBE0 /* download.js in Sources */ = {isa = PBXBuildFile; fileRef = 1C736C2941B8FE7D05658856 /* download.js */; };
1C736E21B246C0BE7E123FD3 /* MediaModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736B41C6AC33F3FA592C63 /* MediaModel.swift */; };
1C736F278DDC77F40C8CB1D4 /* BMPlayerControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736E51F1A03E3A1200BDB6 /* BMPlayerControlView.swift */; };
1C736F3570EADA086682E6BC /* BMPlayerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C7360D6580FB5D09C2BBCCB /* BMPlayerManager.swift */; };
1C736F6A223D4ADB2E1BA733 /* ItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C736069C214E9522BB1BD97 /* ItemCell.swift */; };
1C736FB92B19FE17E4357C85 /* MediaItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C73688DAB88F9360FB62A49 /* MediaItem.swift */; };
AA74B07A01F0E99E6DEC7D1B /* Pods_kplayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B75159FFCD5A882E6F167FE /* Pods_kplayer.framework */; };
C96C752226B55D5F000F4106 /* download.js in Resources */ = {isa = PBXBuildFile; fileRef = 1C736C2941B8FE7D05658856 /* download.js */; };
C98AF5D51B124D6A00D196CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D41B124D6A00D196CC /* AppDelegate.swift */; };
C98AF5D81B124D6A00D196CC /* kplayer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D61B124D6A00D196CC /* kplayer.xcdatamodeld */; };
C98AF5DF1B124D6A00D196CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5DD1B124D6A00D196CC /* Main.storyboard */; };
@ -79,7 +80,6 @@
1C7360D6580FB5D09C2BBCCB /* BMPlayerManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BMPlayerManager.swift; sourceTree = "<group>"; };
1C73610B997EBA367C806C1B /* BMPlayerCompositionResourceDefinition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BMPlayerCompositionResourceDefinition.swift; sourceTree = "<group>"; };
1C73611D226B48C24DB37535 /* MasterViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = "<group>"; };
1C73615FFA2AA98BD1C56CD4 /* links.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = links.html; sourceTree = "<group>"; };
1C73620D01687FB4F1811C5C /* NetworkHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkHelper.swift; sourceTree = "<group>"; };
1C73625012D50E457D18A785 /* kplayer.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = kplayer.js; sourceTree = "<group>"; };
1C736253AB7A95EA41B605B7 /* ItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemModel.swift; sourceTree = "<group>"; };
@ -103,8 +103,9 @@
1C7369F53095B7A4D65679C2 /* DetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
1C736B41C6AC33F3FA592C63 /* MediaModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaModel.swift; sourceTree = "<group>"; };
1C736B794396F2E50387B8F2 /* stringutil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = stringutil.swift; sourceTree = "<group>"; };
1C736BAAC83151BCA0271E83 /* links.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = links.html; sourceTree = "<group>"; };
1C736BC4450890C45F8FBC63 /* LayoutTools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutTools.swift; sourceTree = "<group>"; };
1C736C1368E0DE89BAA2DF60 /* download.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = download.js; sourceTree = "<group>"; };
1C736C2941B8FE7D05658856 /* download.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = download.js; sourceTree = "<group>"; };
1C736C7FFBDAC665AE04CB65 /* VideoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoController.swift; sourceTree = "<group>"; };
1C736D9BB5498E7E8F11C754 /* HeaderCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderCell.swift; sourceTree = "<group>"; };
1C736DBB6986A8B62963FBB3 /* HtmlParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HtmlParser.swift; sourceTree = "<group>"; };
@ -164,8 +165,6 @@
isa = PBXGroup;
children = (
1C73625012D50E457D18A785 /* kplayer.js */,
1C736C1368E0DE89BAA2DF60 /* download.js */,
1C73615FFA2AA98BD1C56CD4 /* links.html */,
);
path = server;
sourceTree = "<group>";
@ -265,6 +264,8 @@
1C736059262A57AADE6AB761 /* Kirschkeks-256x256.png */,
8052F5B3AAC2535E5C08A529 /* Pods */,
1C73685B4BBFDAFBF08C032C /* readme.md */,
1C736BAAC83151BCA0271E83 /* links.html */,
1C736C2941B8FE7D05658856 /* download.js */,
);
sourceTree = "<group>";
};
@ -411,11 +412,12 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C96C752226B55D5F000F4106 /* download.js in Resources */,
C98AF5DF1B124D6A00D196CC /* Main.storyboard in Resources */,
C98AF5E41B124D6A00D196CC /* LaunchScreen.xib in Resources */,
C98AF5E11B124D6A00D196CC /* Images.xcassets in Resources */,
1C736A5FA5BA53B2597F2ED7 /* Kirschkeks-256x256.png in Resources */,
1C73696E4C0353053BF98031 /* links.html in Resources */,
1C736B8E71B9D4A285F96AF3 /* links.html in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -527,7 +529,7 @@
1C736A06A2AD75B8C14EEBBE /* HtmlParser.swift in Sources */,
1C736048BFA120F5C7D36874 /* readme.md in Sources */,
1C736771C503FB0D52AEB8F7 /* kplayer.js in Sources */,
1C736662E43C6E8FFED11AC4 /* download.js in Sources */,
1C736E1B0A79D5925BF7BBE0 /* download.js in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

14
kplayer/AppDelegate.swift

@ -46,12 +46,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
let web = MediaItem(name: "web", path:"", root: "/srv/samba/ren/web", type: ItemType.WEBROOT)
web.loaded = true
let google = MediaItem(name: "google", path:"www.google.de", root: "", type: ItemType.FOLDER)
let a = MediaItem(name: "www.google.de", path:"www.google.de", root: "", type: ItemType.WEB)
google.children = [ a ]
web.children = [
google
]
let google = MediaItem(name: "google", path:"www.google.de", root: "", type: ItemType.DETAILS)
google.loaded = true
web.children = [ google ]
let urlPath = Bundle.main.url(forResource: "links", withExtension: "html")
let parser = HtmlParser(url: urlPath)
parser.parse()
google.children = parser.items
roots.append(NetworkManager.sharedInstance.favorites)
roots.append(web)

1
kplayer/core/HtmlParser.swift

@ -27,6 +27,7 @@ class HtmlParser : NSObject, XMLParserDelegate {
if let value = attributeDict["href"] {
currentItem = MediaItem(name: value, path: value, root: "", type: ItemType.WEB)
currentItem!.loaded = true
items.append(currentItem!)
}
default: break

8
kplayer/core/NetworkManager.swift

@ -30,6 +30,14 @@ class NetworkManager {
internal typealias Weiter = ([MediaItem]) -> Void
func getDownloadJs() -> URL {
if offline {
let url = Bundle.main.url(forResource: "download.js", withExtension: nil)!
return url
}
return URL(string: "http://l inkstation:8089/ren/web/download.js")!
}
func saveFavDir(name: String, item: MediaItem) -> Void {
let json = item.toJSON()
let url = FileHelper.getDocumentsDirectory().appendingPathComponent(name)

3
kplayer/detail/BrowserController.swift

@ -250,7 +250,8 @@ print(url?.absoluteString)
private func executeDocumentDownloadScript(webView: WKWebView, forAbsoluteUrl absoluteUrl : String) {
// TODO: Add more supported mime-types for missing content-disposition headers
do {
let js = try String(contentsOf: URL(string: "http://linkstation:8089/ren/web/download.js")!, encoding: .utf8)
let url = NetworkManager.sharedInstance.getDownloadJs()
let js = try String(contentsOf: url, encoding: .utf8)
let j = js.replacingOccurrences(of: "(absoluteUrl)", with: absoluteUrl)
webView.evaluateJavaScript(j) { (result, err) in
if (err != nil) {

0
kplayer/server/links.html → links.html

Loading…
Cancel
Save