Alan News
Accueil > Technique > Synology Simple Host File

Synology Simple Host File

lundi 15 décembre 2014, par alan

Let’s say you like syology diskstations and particularly the DownloadStation application.
That you subscribe to a third-party download site, that permits the http SIMPLE authentication
(the form https://username:password@www.mysupersite.com/resource)
You can write a custom host file in :
/usr/syno/synoman/webman/3rdparty/DownloadStation/hostscript/hosts/mysupersite directory.

INFO :
{
"name" : "mysupersite",
"hostprefix" : "mysupersitde.com",
"displayname" :
"My Super Site",
"version" : "1.0",
"authentication" : "yes",
"module" : "mysupersite.php",
"class" : "SynoFileHostingMySuperSite",
"description" : "Premium or free account supported."
}

mysupersite.php :
<?php
/* Copyright (c) 2014 Alan Guegan. All rights reserved. */
class SynoFileHostingMySuperSite {
        private 
$Url;
        private 
$Username;
        private 
$Password;
        private 
$HostInfo;
        public function 
__construct($Url$Username$Password$HostInfo) {
                
$this->Url $Url;
                
$this->Username $Username;
                
$this->Password $Password;
                
$this->HostInfo $HostInfo;
        }
//This function returns download url.
public function GetDownloadInfo() {
        
$ret FALSE;
        
$ret $this->DownloadPremium($this->CookieValue);
        return 
$ret;
}
//This function verifies and returns a ccount type.
public function Verify($ClearCookie)
{
        
$ret USER_IS_PREMIUM;
        return 
$ret;
}
//This function get premium download url.
private function DownloadPremium($CookieValue) {
        
preg_match("/^(https?:\/\/)(.*)$/"$this->Url$DownloadID);

        if (!empty(
$DownloadID[1])) {
                
$returl $DownloadID[1] . $this->Username ":" $this->Password "@" $DownloadID[2];
                
$DownloadInfo = array();
                
$DownloadInfo[DOWNLOAD_URL] = trim($returl);
        }
        return 
$DownloadInfo;
}
}
?>

Then you access the synology DSM, the DownloadStation application, ’configure’ in the lower bar, then ’File Hosting’. Your entry for ’mysupersite’ should be present in that list. Click on modify then enter your username & password.

Of course the official packaging method for those host files is the tar
go to your directory then

tar cvf mysupersite.host INFO mysupersite.php

Then that mysupersite.info is uploadable into your synology via your ’Add File Hosting site’ button

http://ukdl.synology.com/download/D...

P.-S.

Enjoy

Répondre à cet article

SPIP | squelette | | Plan du site | Suivre la vie du site RSS 2.0