diff --git a/controller/Controller.class.php b/controller/Controller.class.php index 7ae3f310..0604de27 100644 --- a/controller/Controller.class.php +++ b/controller/Controller.class.php @@ -140,7 +140,8 @@ class Controller } } - $router->any('/get/lbry.{ext:c}', 'DownloadActions::executeGetRedirect'); + $router->any('/get/lbry.{ext:c}', 'DownloadActions::executeGetAppRedirect'); + $router->any('/get/lbrynet.{os:c}.zip', 'DownloadActions::executeGetDaemonRedirect'); $router->get([ContentActions::URL_NEWS . '/{slug:c}?', 'news'], 'ContentActions::executeNews'); $router->get([ContentActions::URL_FAQ . '/{slug:c}?', 'faq'], 'ContentActions::executeFaq'); diff --git a/controller/action/DeveloperActions.class.php b/controller/action/DeveloperActions.class.php index c3019704..75190eb2 100644 --- a/controller/action/DeveloperActions.class.php +++ b/controller/action/DeveloperActions.class.php @@ -50,9 +50,11 @@ class DeveloperActions extends Actions public static function prepareQuickstartInstallPartial(array $vars) { - return $vars + [ - 'version' => 'foo' - ]; + return $vars + ['versions' => [ + Os::OS_LINUX => Github::getDaemonReleaseProperty(OS::OS_LINUX, 'tag_name'), + Os::OS_OSX => Github::getDaemonReleaseProperty(OS::OS_OSX, 'tag_name'), + Os::OS_WINDOWS => Github::getDaemonReleaseProperty(OS::OS_WINDOWS, 'tag_name'), + ]]; } public static function prepareFormNewDeveloperRewardPartial(array $vars) diff --git a/controller/action/DownloadActions.class.php b/controller/action/DownloadActions.class.php index 227c3817..afda9134 100644 --- a/controller/action/DownloadActions.class.php +++ b/controller/action/DownloadActions.class.php @@ -2,7 +2,7 @@ class DownloadActions extends Actions { - public static function executeGetRedirect(string $ext) + public static function executeGetAppRedirect(string $ext) { $uri = null; switch ($ext) @@ -23,6 +23,19 @@ class DownloadActions extends Actions return Controller::redirect($uri ?: '/get', 302); } + public static function executeGetDaemonRedirect(string $os) + { + $uri = null; + $oses = Os::getAll(); + + if (isset($oses[$os])) + { + $uri = GitHub::getDaemonDownloadUrl($os); + } + + return Controller::redirect($uri ?: '/quickstart', 302); + } + public static function executeGet() { $email = Request::getParam('e'); diff --git a/lib/thirdparty/Github.class.php b/lib/thirdparty/Github.class.php index 676a212c..729e3902 100644 --- a/lib/thirdparty/Github.class.php +++ b/lib/thirdparty/Github.class.php @@ -32,7 +32,7 @@ class Github return null; } - public static function getDaemonDownloadUrl($os, $cache = true) + public static function getDaemonReleaseProperty($os, $property, $isAssetProperty = false, $cache = true) { if (!in_array($os, array_keys(OS::getAll()))) { @@ -44,17 +44,13 @@ class Github $releaseData = static::get('/repos/lbryio/lbry/releases/latest', $cache); foreach ($releaseData['assets'] as $asset) { - echo '
'; - print_r($asset); - echo ''; - $ext = substr($asset['name'], -4); if ( - ($os == OS::OS_LINUX && ($ext == '.deb' || in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb']))) || - ($os == OS::OS_OSX && ($ext == '.dmg' || in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage']))) || - ($os == OS::OS_WINDOWS && $ext == '.exe') + ($os == OS::OS_LINUX && stripos($asset['browser_download_url'], 'linux') !== false) || + ($os == OS::OS_OSX && stripos($asset['browser_download_url'], 'macos') !== false) || + ($os == OS::OS_WINDOWS && strpos($asset['browser_download_url'], 'windows') !== false) ) { - return $asset['browser_download_url']; + return $isAssetProperty ? $asset[$property] : $releaseData[$property]; } } } @@ -65,6 +61,11 @@ class Github return null; } + public static function getDaemonDownloadUrl($os, $cache = true) + { + return static::getDaemonReleaseProperty($os, 'browser_download_url', true); + } + public static function get($endpoint, $cache = true) { $twoHoursInSeconds = 7200; diff --git a/view/template/developer/_quickstartApi.php b/view/template/developer/_quickstartApi.php index 55fe94b8..2517aecb 100644 --- a/view/template/developer/_quickstartApi.php +++ b/view/template/developer/_quickstartApi.php @@ -1,4 +1,4 @@ -
When running, the LBRY daemon provides a JSON-RPC server running at http://localhost:5279/lbryapi
.
Above, we called the method resolve_name
for the URL lbry://what
. This returned the metadata associated with the URL.
Now let's download it. This time we're going to call the method get
with the same parameters.
$curl 'http://localhost:5279/lbryapi' --data '{"method":"get","params":{"name":"what"} }'
-["d5169241150022f996fa7cd6a9a1c421937276a3275eb912790bd07ba7aec1fac5fd45431d226b8fb402691e79aeb24b"]
+[
+ {
+ //some response fields omitted for brevity
+ "claim_id": "7b670f0034d0eb119c32acfe8b19ae6622dd218f", //a claim ID is persistent for a piece of content. It stays the same if the original publisher updates the entry.
+ "download_directory": "/home/kauffj/Downloads",
+ "download_path": "/home/kauffj/Downloads/LBRY100.mp4",
+ "file_name": "LBRY100.mp4",
+ "metadata": { ... }, //same dictionary as above
+ "outpoint": "6e224057a9dfa3417bb3890da2c4b4e9d2471641185c6c8b33cb57d61365a4f0:1", //an outpoint is a frozen-in-time pointer to a specific piece of content. It changes if the content changes.
+ "total_bytes": 158433904,
+ "written_bytes": 0 //will increase as the file downloads
+ }
+]
+This file will download in the background to the download_directory
specified in the returned data. Subsequent calls to get
or file_list
will return the status.
The LBRY API consists of about 50 calls, all related to discovering, distributing, and purchasing content. View the full API documentation.
You can also list all of the commands available by calling the help command.
$curl 'http://localhost:5279/lbryapi' --data '{"method":"help"}'
diff --git a/view/template/developer/_quickstartCredits.php b/view/template/developer/_quickstartCredits.php
index 275b59a3..73d24d59 100644
--- a/view/template/developer/_quickstartCredits.php
+++ b/view/template/developer/_quickstartCredits.php
@@ -38,9 +38,21 @@
Enjoy a Hollywood Film
It's a Disaster starring David Cross is just one of tens of thousands of great pieces of content available. Check it out!
$curl 'http://localhost:5279/lbryapi' --data '{"method":"get","params":{"name":"itsadisaster"} }'
-["d5169241150022f996fa7cd6a9a1c421937276a3275eb912790bd07ba7aec1fac5fd45431d226b8fb402691e79aeb24b"]
+[
+ {
+ //some response fields omitted for brevity
+ "claim_id": "bd970a51249cba542a9acfb130147294a6326ee2",
+ "download_directory": "/home/kauffj/Downloads",
+ "download_path": "/home/kauffj/Downloads/It's A Disaster_Feature.mp4",
+ "metadata": {
+ "author": "Written and directed by Todd Berger",
+ "content_type": "video/mp4",
+ "description": "Four couples meet for Sunday brunch only to discover they are stuck in a house together as the world may be about to end."
+ }
+ }
+]
LBRY comes with a UI so that normal people can use it too. You can download it here.
+LBRY comes with a fully-featured UI so that normal people can use it too. You can download it here.
Start building something awesome! LBRY works as a discovery and distribution backend for everything from films to CAD files. diff --git a/view/template/developer/_quickstartInstall.php b/view/template/developer/_quickstartInstall.php index 60911c4c..45c023cf 100644 --- a/view/template/developer/_quickstartInstall.php +++ b/view/template/developer/_quickstartInstall.php @@ -1,9 +1,4 @@
- - - -
Download .dmg | -Download .deb | -Download .msi | +Download | +Download | +Download |
LBRY is 100% open source in the Bazaar tradition.
- -LBRY is 100% open source in the Bazaar tradition.
+ +