Better way write worm code with Swift.
Downloading files from many cloud storage platforms can be cumbersome, requiring multiple page redirects. Through studying the download process, it was discovered that they are all patched together like monsters, and some of the download processes are the same. Theoretically, it is possible to solidify the necessary processes into different modules and link them together, which can be reused across different cloud storage platforms.
This framework serves as the foundation for other apps, and one of the core abilities of the app I am developing is to automatically parse download links and enable one-click downloads using this framework. In the future, more straightforward APIs will be updated.
Support Site | Module | Status |
---|---|---|
www.xueqiupan.com | DownPage γPHPLinks |
done |
rosefile.net | AppendDownPath γFileIDStringInDomSearchGroup γGeneralLinks |
done |
www.xunniufile.com | DownPage γPHPLinks |
done |
www.xingyaoclouds.com | RedirectEnablePage γActionDownPage γPHPLinks |
done |
www.567file.com | - | server 500 error |
www.xfpan.cc | - | working on |
www.kufile.net | - | waitting |
let link = "http://www.xueqiupan.com/file-672734.html"
cancellable = DownPage(.default)
.join(PHPLinks())
.join(Saver(.override))
.publisher(for: link)
.sink { complete in
switch complete {
case .finished:
break
case .failure(let error):
print(">>> download error \(error)")
}
} receiveValue: { url in
print(">>> download file at \(url)")
}
The file will download at your Downloads
folder.
Just confirm Condom
protocol make simple download HTML page operation become async module
struct DownloadWebPage: Condom {
typealias Input = URL
typealias Output = String
public func publisher(for inputValue: Input) -> AnyPublisher<Output, Error> {
// tool for data -> string
StringParserDataTask(request: .init(url: inputValue), encoding: .utf8)
.publisher()
}
public func empty() -> AnyPublisher<Output, Error> {
Fail(error: URLError(.badURL)).eraseToAnyPublisher()
}
}
Then get publisher out of itοΌand sink to fire it up!
DownloadWebPage()
.publisher(for: link)
.sink { complete in
switch complete {
case .finished:
break
case .failure(let error):
print(">>> download error \(error)")
}
} receiveValue: { text in
print(">>> html: \(text)")
}
Carthage is a simple, decentralized dependency manager for Cocoa.
Specify WebShell into your project's Cartfile
:
github "0xfeedface1993/WebShell" ~> 3.0
From Xcode, select from the menu File > Swift Packages > Add Package Dependency Specify the URL https://github.com/0xfeedface1993/WebShell
As you can see, this project need more work, so if you want join me, any pull request will be helpful!
link |
Stars: 7 |
Last commit: 2 days ago |
Full Changelog: https://github.com/0xfeedface1993/WebShell/compare/2.5.0...v3.0
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics