diff --git a/README.md b/README.md index 7a08d0f..12ebf40 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # KoboCloud -A set of scripts to synchronize a kobo reader with popular cloud services. +A set of scripts to synchronize a kobo reader with popular cloud services, using [rclone](https://rclone.org). -The following cloud services are supported: +Some example supported cloud services: - Dropbox - Google Drive @@ -9,6 +9,9 @@ The following cloud services are supported: - pCloud - Box +There are many more - see https://rclone.org/docs/ for the full list. + + ## Installation Download the latest `KoboRoot.tgz` from the Release page (or using [this direct link](https://github.com/fsantini/KoboCloud/releases/download/latest/KoboRoot.tgz)). @@ -27,76 +30,28 @@ Copy it into the Kobo device: After the installation process: -- Plug your Kobo back into the computer -- Open the configuration file located at `.add/kobocloud/kobocloudrc` -- Add the links to the cloud services (one per line) +1. [Download](https://rclone.org/downloads/) rclone to your computer +2. Run `rclone config` to create a config file and add your remote Cloud services ([detailed instructions](https://rclone.org/remote_setup/#configuring-by-copying-the-config-file)). + - You can add as many remote Cloud services as you need, but note the name you give each remote. +3. Plug your Kobo back into the computer +4. Copy the rclone config file to `.add/kobocloud/rclone.conf` + - Run `rclone config file` on your computer to find the file. +5. Edit the configuration file located at `.add/kobocloud/kobocloudrc`, and add each remote:directory pair (one per line). + +## Configuration example -Configuration example: +(Note: this is after going through the configuraton steps above) ``` # Lines starting with '#' are ignored # Google drive: -https://drive.google.com/drive/folders/?usp=sharing +my_google_drive:foldername + # Dropbox: -https://www.dropbox.com/sh/pgSHORTENED -REMOVE_DELETED +my_dropbox:other/folder/name ``` -Some important advice: -- make sure that there are **no spaces** before or after the link on the line -- **no subdirectories** are supported at the moment, your books must be all in the same directories that you are sharing -- **restart your Kobo** after any kobocloudrc changes to to make them effective - -### Dropbox public folder - -Due to a change in Dropbox website, the public folder method does not work anymore. - -### Dropbox private folder - -This method will create a folder `/Applications/Kobo Cloud Sync` in your Dropbox and sync with it. - -- Open this [link](https://www.dropbox.com/oauth2/authorize?response_type=code&token_access_type=offline&client_id=5oyw72cfwcp352f&code_challenge_method=plain&code_challenge=0000000000000000000000000000000000000000000&redirect_uri=https://louisabraham.github.io/KoboCloud/) -- Paste the command in a terminal -- Copy the line starting with `DropboxApp:` from your terminal -- Add it to your `kobocloudrc` file - -### Google Drive - -- Use the "link sharing" option on a Google Drive folder -- Select the option "anyone with the link can view." -- Copy-paste the link in the kobocloudrc file - -Subdirectories are supported for Google Drive. -**Important**: Folders with many files might not work. - -### Nextcloud (Owncloud) - -To add a NextCloud (ownCloud) link: - -- Open your nextcloud website in a browser -- Select the folder that you want to share -- Click on "Share" and select "Share with link" -- Copy the link into the kobocloudrc file - -Please note that you need a recent NextCloud (OwnCloud) version. -Subdirectories are supported for NextCloud (OwnCloud). - -**Important**: Webdav for public folders should be enabled, see: https://docs.nextcloud.com/server/20/user_manual/en/files/access_webdav.html#accessing-public-shares-over-webdav for more info. - -### pCloud - -- Add the public link to the containing folder to the kobocloudrc file. - -~~Files added into a subfolder of the *public* folder of pCloud are also supported.~~ -Due to a different download method for pCloud (new share links have a different format) subfolders are only supported on the older share folders. Not on the newer ones. - -### Box - -- On a Box folder, click "Create link" in the sidebar and enable "Share Link" -- Select the options "People with the link" and "can view and download" -- Copy-paste the link in the kobocloudrc file - -Please note that, even though the script supports folders where the file list has multiple pages, having a list with many pages might not work. +rclone supports many, many other remote types. See https://rclone.org/docs/ for the full list. ### Matching remote server To delete files from library when they are no longer in the remote server: @@ -106,6 +61,8 @@ To delete files from library when they are no longer in the remote server: The next time the Kobo is connected to the internet, it will delete any files (it will not delete directories) that are not in the remote server. +(This works by running `rclone sync` instead of `rclone copy`), + ## Usage @@ -147,7 +104,6 @@ KoboCloud keeps a log of each session in the .add/kobocloud/get.log file. If som ## Known issues -* Subfolder support is limited. * Some versions of Kobo make the same book appear twice in the library. This is because it scans the internal directory where the files are saved as well as the "official" folders. To solve this problem find the `Kobo eReader.conf` file inside your `.kobo/Kobo` folder and make sure the following line (which prevents the syncing of dotfiles and dotfolders) is set in the `[FeatureSettings]` section: ``` ExcludeSyncFolders=\\.(?!add|adobe).*? diff --git a/src/usr/local/kobocloud/config_kobo.sh b/src/usr/local/kobocloud/config_kobo.sh index b0583b9..e3b25b7 100755 --- a/src/usr/local/kobocloud/config_kobo.sh +++ b/src/usr/local/kobocloud/config_kobo.sh @@ -3,6 +3,8 @@ Logs=/mnt/onboard/.add/kobocloud Lib=/mnt/onboard/.add/kobocloud/Library SD=/mnt/sd/kobocloud UserConfig=/mnt/onboard/.add/kobocloud/kobocloudrc +RCloneConfig=/mnt/onboard/.add/kobocloud/rclone.conf Dt="date +%Y-%m-%d_%H:%M:%S" -CURL="$KC_HOME/curl --cacert \"$KC_HOME/ca-bundle.crt\" " +RCLONEDIR="/mnt/onboard/.add/kobocloud/bin/" +RCLONE="${RCLONEDIR}rclone" PLATFORM=Kobo diff --git a/src/usr/local/kobocloud/config_pc.sh b/src/usr/local/kobocloud/config_pc.sh index 5919d79..8bab491 100755 --- a/src/usr/local/kobocloud/config_pc.sh +++ b/src/usr/local/kobocloud/config_pc.sh @@ -3,6 +3,8 @@ Logs=/tmp/KoboCloud Lib=/tmp/KoboCloud/Library SD=/tmp/KoboCloud/sd UserConfig=/tmp/KoboCloud/kobocloudrc +RCloneConfig=~/.config/rclone/rclone.conf Dt="date +%Y-%m-%d_%H:%M:%S" -CURL=/usr/bin/curl +RCLONEDIR="/usr/bin/" +RCLONE="${RCLONEDIR}rclone" PLATFORM=PC diff --git a/src/usr/local/kobocloud/curl b/src/usr/local/kobocloud/curl deleted file mode 100755 index f994326..0000000 Binary files a/src/usr/local/kobocloud/curl and /dev/null differ diff --git a/src/usr/local/kobocloud/get.sh b/src/usr/local/kobocloud/get.sh index c2c478c..910988b 100755 --- a/src/usr/local/kobocloud/get.sh +++ b/src/usr/local/kobocloud/get.sh @@ -44,56 +44,45 @@ then echo "NickelDBus found" else echo "NickelDBus not found: installing it!" - $CURL -k -L "https://github.com/shermp/NickelDBus/releases/download/0.2.0/KoboRoot.tgz" | tar xz -C / + wget "https://github.com/shermp/NickelDBus/releases/download/0.2.0/KoboRoot.tgz" -O - | tar xz -C / + fi + if [ -f "${RCLONE}" ] + then + echo "rclone found" + else + echo "rclone not found: installing it!" + mkdir -p "${RCLONEDIR}" + rcloneTemp="${RCLONEDIR}/rclone.tmp.zip" + rm -f "${rcloneTemp}" + wget "https://github.com/rclone/rclone/releases/download/v1.64.0/rclone-v1.64.0-linux-arm-v7.zip" -O "${rcloneTemp}" + unzip -p "${rcloneTemp}" rclone-v1.64.0-linux-arm-v7/rclone > ${RCLONE} + rm -f "${rcloneTemp}" fi fi while read url || [ -n "$url" ]; do - echo "Reading $url" if echo "$url" | grep -q '^#'; then - echo "Comment found" + continue elif echo "$url" | grep -q "^REMOVE_DELETED$"; then - echo "Will match remote" - else - echo "Getting $url" - if echo $url | grep -q '^https*://www.dropbox.com'; then # dropbox link? - $KC_HOME/getDropboxFiles.sh "$url" "$Lib" - elif echo $url | grep -q '^DropboxApp:'; then # dropbox token - auth=`echo $url | sed -e 's/^DropboxApp://' -e 's/[[:space:]]*$//'` - client_id=`echo $auth | sed 's/:.*//'` - refresh_token=`echo $auth | sed 's/.*://'` - $KC_HOME/getDropboxAppFiles.sh "$client_id" "$refresh_token" "$Lib" - elif echo $url | grep -q '^https*://filedn.com\|^https*://filedn.eu\|^https*://[^/]*pcloud'; then - $KC_HOME/getpCloudFiles.sh "$url" "$Lib" - elif echo $url | grep -q '^https*://drive.google.com'; then - $KC_HOME/getGDriveFiles.sh "$url" "$Lib" - elif echo $url | grep -q '^https*://app.box.com'; then - $KC_HOME/getBoxFiles.sh "$url" "$Lib" + echo "Will delete files no longer present on remote" + elif [ -n "$url" ]; then + echo "Getting $url" + command="" + if grep -q "^REMOVE_DELETED$" $UserConfig; then + # Remove deleted, do a sync. + command="sync" else - $KC_HOME/getOwncloudFiles.sh "$url" "$Lib" + # Don't remove deleted, do a copy. + command="copy" fi + remote=$(echo "$url" | cut -d: -f1) + dir="$Lib/$remote/" + mkdir -p "$dir" + echo ${RCLONE} ${command} --no-check-certificate -v --config ${RCloneConfig} \"$url\" \"$dir\" + ${RCLONE} ${command} --no-check-certificate -v --config ${RCloneConfig} "$url" "$dir" fi done < $UserConfig -recursiveUpdateFiles() { -for item in *; do - if [ -d "$item" ]; then - (cd -- "$item" && recursiveUpdateFiles) - elif grep -Fq "$item" "$Lib/filesList.log"; then - echo "$item found" - else - echo "$item not found, deleting" - rm "$item" - fi -done -} - -if grep -q "^REMOVE_DELETED$" $UserConfig; then - cd "$Lib" - echo "Matching remote server" - recursiveUpdateFiles -fi - if [ "$TEST" = "" ] then # Use NickelDBus for library refresh diff --git a/src/usr/local/kobocloud/getBoxFiles.sh b/src/usr/local/kobocloud/getBoxFiles.sh deleted file mode 100755 index 8de8e09..0000000 --- a/src/usr/local/kobocloud/getBoxFiles.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -baseURL="$1" -outDir="$2" - -#load config -. $(dirname $0)/config.sh - -currPage=1 - -# get directory listing -echo "Getting $baseURL" - -boxDirCode=`echo $baseURL | sed 's@.*/\(.*\)$@\1@'` - -pageContent=`$CURL -k -L --silent "$baseURL"` -numPages=`echo $pageContent | grep -Eo 'pageCount":[0-9]+,' | sed -n 's/pageCount":\([0-9]*\),/\1/p'` - -while [ "$currPage" -le "$numPages" ] -do - echo "$pageContent" | - grep -Eo 'typedID":"[^"]+","type":"file","id":[0-9]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,"name":"[^"]+"' | # find links - while read fileInfo - do - #echo "File info: $fileInfo" - fileCode=`echo $fileInfo | sed -n 's/.*typedID":"\([^"]*\).*/\1/p'` # extract the code for file download (this is how a file is identified in Box) - fileName=`echo $fileInfo | sed -n 's/.*"name":"\([^"]\+\)".*/\1/p'` # extract the file name - linkLine="https://app.box.com/index.php?rm=box_download_shared_file&shared_name=$boxDirCode&file_id=$fileCode" - outFileName=`echo $fileName | sed 's/\\u[0-9a-f]\{4\}/_/g' | tr ' ' '_'` - #echo $outFileName - localFile="$outDir/$outFileName" - $KC_HOME/getRemoteFile.sh "$linkLine" "$localFile" - - if [ $? -ne 0 ] ; then - echo "Having problems contacting Box. Try again in a couple of minutes." - exit - fi - done - - currPage=$((currPage + 1)) - if [ "$currPage" -le "$numPages" ] ; then - echo "Fetching page $currPage from $baseURL?page=$currPage" - pageContent=$($CURL -k -L --silent "$baseURL?page=$currPage") - fi - -done diff --git a/src/usr/local/kobocloud/getDropboxAppFiles.sh b/src/usr/local/kobocloud/getDropboxAppFiles.sh deleted file mode 100755 index 255c885..0000000 --- a/src/usr/local/kobocloud/getDropboxAppFiles.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -client_id="$1" -refresh_token="$2" -outDir="$3" - -#load config -. $(dirname $0)/config.sh -token=`$CURL -k --silent https://api.dropbox.com/oauth2/token \ - -d grant_type=refresh_token \ - -d client_id=$client_id \ - -d refresh_token=$refresh_token | - sed 's/.*"access_token": "\([^"]*\)", ".*/\1/'` - -# get directory listing -response=$($CURL -k --silent -X POST https://api.dropboxapi.com/2/files/list_folder \ - --header "Authorization: Bearer $token" \ - --header "Content-Type: application/json" \ - --data '{"path": "","include_non_downloadable_files": false}') -echo "$response" | -sed -e 's/^.*\[{//' -e 's/}\].*$//' -e 's/}, {/\n/g' | -grep '".tag": "file"' | grep '"is_downloadable": true' | -while read item -do - outFileName=`echo $item | sed -e 's/.*"name": "\([^"]*\)", ".*/\1/'` - outFileName=`echo $outFileName | sed -e 's/\\u00e0/à/' -e 's/\\u00e0/â/' -e 's/\\u00e8/è/' -e 's/\\u00e9/é/' -e 's/\\u00f8/ø/' -e 's/\\u0153/œ/'` - remotePath=`echo $item | sed 's/.*"id": "\([^"]*\)", ".*/\1/'` - localFile="$outDir/$outFileName" - $KC_HOME/getRemoteFile.sh "https://content.dropboxapi.com/2/files/download" "$localFile" "$token" "$remotePath" - if [ $? -ne 0 ] ; then - echo "Having problems contacting Dropbox. Try again in a couple of minutes." - exit - fi -done diff --git a/src/usr/local/kobocloud/getDropboxFiles.sh b/src/usr/local/kobocloud/getDropboxFiles.sh deleted file mode 100755 index a53ed05..0000000 --- a/src/usr/local/kobocloud/getDropboxFiles.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -baseURL="$1" -outDir="$2" - -#load config -. $(dirname $0)/config.sh - -baseURL=`echo "$baseURL" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'` - -# get directory listing -echo "Getting $baseURL" -# get directory listing -$CURL -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36" -k -L --silent "$baseURL" | # get listing. Need to specify a user agent, otherwise it will download the directory -grep -Eo 'ShmodelFolderEntriesPrefetch.*' | -grep -Eo 'https?://www.dropbox.com/sh/[^\"]*' | # find links -sort -u | # remove duplicates -while read linkLine -do - if [ "$linkLine" = "$baseURL" ] - then - continue - fi - #echo $linkLine - # process line - outFileName=`echo $linkLine | sed -e 's|.*/\(.*\)?dl=.*|\1|'` - #echo $outFileName - localFile="$outDir/$outFileName" - $KC_HOME/getRemoteFile.sh "$linkLine" "$localFile" - if [ $? -ne 0 ] ; then - echo "Having problems contacting Dropbox. Try again in a couple of minutes." - exit - fi -done diff --git a/src/usr/local/kobocloud/getGDriveFiles.sh b/src/usr/local/kobocloud/getGDriveFiles.sh deleted file mode 100755 index 8ffb2e5..0000000 --- a/src/usr/local/kobocloud/getGDriveFiles.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -baseURL="$1" -outDir="$2" - -#load config -. $(dirname $0)/config.sh - -find_files() #function to find all files in the folder -{ - -$CURL -k -L --silent "https://drive.google.com/drive/folders/$1" | -grep -Eo "\\\x5b\\\x22[^\\\]*\\\x22,\\\x5b\\\x22$1\\\x22\\\x5d,\\\x22.{1,250}\\\x22,\\\x22[^\\\]*\\\/[^\\\]*" | -sed 's/\\\x/\\\\\x/g' | -while read entry -do - entryType=`echo $entry | sed -n 's/.*\\\x22\(.*\)$/\1/p'` #Get the type. Needed to see if it's a file or a folder. - entryCode=`echo $entry | sed -n 's/\\\x5b\\\x22\(.*\)\\\x22,\\\x5b\\\x22.*$/\1/p'` #Get the identifying code of the file/folder - entryName=`echo $entry | sed -n 's|\\\x5b\\\x22.*,\\\x22\(.*\)\\\x22,\\\x22.*$|\1|p'` - - if [ "$entryType" = "application/vnd.google-apps.folder" ]; then #if it's a folder it runs this function for the folder - find_files $entryCode "$entryName/" - else - echo "$2$entryName|$entryCode" - fi -done -} - -# get directory listing -echo "Getting $baseURL" -# get directory listing - -gDirCode=`echo $baseURL | sed 's@.*/\([^/\?]*\).*@\1@'` - -echo $gDirCode - -links=`find_files "$gDirCode"` # find links -echo "$links" | -sed 's/\\\x/\\\\\x/g' | -while read fileInfo -do - echo "File info: $fileInfo" - fileCode=`echo $fileInfo | sed -n 's/.*|\(.*\)/\1/p'` # extract the code for file download (this is how a file is identified in GDrive) - fileName=`echo $fileInfo | sed -n 's/\(.*\)|.*/\1/p'` # extract the file name - echo "File code: $fileCode" - echo "File name: $fileName" - linkLine="https://drive.google.com/uc?id=$fileCode&export=download" - outFileName=`/bin/echo -e "$fileName" | tr ' ' '_' ` - localFile="$outDir/$outFileName" - - $KC_HOME/getRemoteFile.sh "$linkLine" "$localFile" - if [ $? -ne 0 ] ; then - echo "Having problems contacting Google Drive. Try again in a couple of minutes." - exit - fi -done diff --git a/src/usr/local/kobocloud/getOwncloudFiles.sh b/src/usr/local/kobocloud/getOwncloudFiles.sh deleted file mode 100755 index 301e5a5..0000000 --- a/src/usr/local/kobocloud/getOwncloudFiles.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -#function to percent-decode the filename from the OwnCloud URL -percentDecodeFileName() { printf "%b\n" "$(sed 's/+/ /g; s/%\([0-9a-f][0-9a-f]\)/\\x\1/g;')"; } - -baseURL="$1" -outDir="$2" - -#load config -. $(dirname $0)/config.sh - -# webdav implementation -# https://myserver.com/s/shareLink -# or -# https://myserver.com/nextcloud/s/sharelink - -shareID=`echo $baseURL | sed -e 's@.*s/\([^/ ]*\)$@\1@'` - -# Extract the path. -path="$(echo $baseURL | grep / | cut -d/ -f4-)" -# Get the servername with path, used to get the file listing. (e.g. if the server uses domain.name/nextcloud, the nextcloud is kept as well.) -davServerWithOwncloudPath=`echo $baseURL | sed -e 's@.*\(http.*\)/s/[^/ ]*$@\1@' -e 's@/index\.php@@'` -# Remove the path to get the protocol and main domain only (used with the relative paths which are a result of "getOwncloudList.sh".) -davServer=$(echo $1 | sed -e s,/$path,,g) - -echo "shareID: $shareID" -echo "davServer: $davServer" -echo "davServerWithOwncloudPath: $davServerWithOwncloudPath" - -# get directory listing -$KC_HOME/getOwncloudList.sh $shareID $davServerWithOwncloudPath | -while read relativeLink -do - # process line - outFileName=`echo $relativeLink | sed 's/.*public.php\/webdav\///' | percentDecodeFileName` - linkLine=$davServer$relativeLink - localFile="$outDir/$outFileName" - # get remote file - $KC_HOME/getRemoteFile.sh "$linkLine" "$localFile" $shareID - if [ $? -ne 0 ] ; then - echo "Having problems contacting Owncloud. Try again in a couple of minutes." - exit - fi -done diff --git a/src/usr/local/kobocloud/getOwncloudList.sh b/src/usr/local/kobocloud/getOwncloudList.sh deleted file mode 100755 index b2f2a5c..0000000 --- a/src/usr/local/kobocloud/getOwncloudList.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -user="$1" -davServer="$2" - -#load config -. $(dirname $0)/config.sh - -echo ' - - -' | -$CURL -k --silent -i -X PROPFIND -u $user: $davServer/public.php/webdav --upload-file - -H "Depth: infinity" | # get the listing -grep -Eo '[^<]*[^/]' | # get the links without the folders -sed 's@@@g' diff --git a/src/usr/local/kobocloud/getRemoteFile.sh b/src/usr/local/kobocloud/getRemoteFile.sh deleted file mode 100755 index 3582b64..0000000 --- a/src/usr/local/kobocloud/getRemoteFile.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -retry="TRUE" - -if [ "$1" = "NORETRY" ] -then - retry="FALSE" - shift 1 -fi - -linkLine="$1" -localFile="$2" -user="$3" -dropboxPath="$4" -outputFileTmp="/tmp/kobo-remote-file-tmp.log" - -# add the epub extension to kepub files -if echo "$localFile" | grep -Eq '\.kepub$' -then - localFile="$localFile.epub" -fi - -#load config -. $(dirname $0)/config.sh - -curlCommand="$CURL" -if [ ! -z "$user" ] && [ "$user" != "-" ]; then - echo "User: $user" - curlCommand="$curlCommand -u $user: " -fi - -if [ ! -z "$dropboxPath" ] && [ "$dropboxPath" != "-" ]; then - curlCommand="$CURL -X POST --header \"Authorization: Bearer $user\" --header \"Dropbox-API-Arg: {\\\"path\\\": \\\"$dropboxPath\\\"}\"" -fi - -echo "Download:" $curlCommand -k --silent -C - -L --create-dirs -o \"$localFile\" \"$linkLine\" -v - -eval $curlCommand -k --silent -C - -L --create-dirs -o \"$localFile\" \"$linkLine\" -v 2>$outputFileTmp -status=$? -echo "Status: $status" -echo "Output: " -cat $outputFileTmp - -statusCode=`grep 'HTTP/' "$outputFileTmp" | tail -n 1 | cut -d' ' -f3` -grep -q "Cannot resume" "$outputFileTmp" -errorResume=$? -rm $outputFileTmp - -echo "Remote file information:" -echo " Status code: $statusCode" - -if echo "$statusCode" | grep -q "403"; then - echo "Error: Forbidden" - exit 2 -fi -if echo "$statusCode" | grep -q "50.*"; then - echo "Error: Server error" - if [ $errorResume ] && [ "$retry" = "TRUE" ] - then - echo "Can't resume. Checking size" - contentLength=$(eval $curlCommand -k -sLI "$linkLine" | grep -i 'Content-Length' | sed 's/.*:\s*\([0-9]*\).*/\1/') - existingLength=`stat --printf="%s" "$localFile"` - echo "Remote length: $contentLength" - echo "Local length: $existingLength" - if [ $contentLength = 0 ] || [ $existingLength = $contentLength ] - then - echo "Not redownloading - Size not available or file already downloaded" - else - echo "Retrying download" - rm "$localFile" - $0 NORETRY "$@" - fi - else - exit 3 - fi -fi - -if grep -q "^REMOVE_DELETED" $UserConfig; then - echo "$localFile" >> "$Lib/filesList.log" - echo "Appended $localFile to filesList" -fi -echo "getRemoteFile ended" - diff --git a/src/usr/local/kobocloud/getpCloudFiles.sh b/src/usr/local/kobocloud/getpCloudFiles.sh deleted file mode 100755 index d8f1d5b..0000000 --- a/src/usr/local/kobocloud/getpCloudFiles.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -baseURL="$1" -outDir="$2" -foundOldWay=false -#load config -. $(dirname $0)/config.sh - -code=`echo $baseURL | sed 's/.*code=\([a-zA-Z0-9]*\).*/\1/'` - -# get directory listing -#echo "Getting $baseURL" -echo "Using pCloud scraping, do not use subfolders, these might not be downloaded." -# get directory listing -$CURL -k -L --silent "$baseURL" | -grep -Eo '"fileid": [0-9]+' | -sed 's/"fileid": \([0-9]*\)/\1/' | # find links -while read fileid -do - foundOldWay=true - echo "FileID: "$fileid - - # get public ID - jsonAns=`$CURL -k -L --silent "https://api.pcloud.com/getpublinkdownload?code=$code&forcedownload=1&fileid=$fileid"` - echo "jsonAns1: "$jsonAns - - if echo $jsonAns | grep -q "error" # try European API - then - jsonAns=`$CURL -k -L --silent "https://eapi.pcloud.com/getpublinkdownload?code=$code&forcedownload=1&fileid=$fileid"` - echo "jsonAns2: "$jsonAns - fi - - if echo $jsonAns | grep -q "error" - then - echo "Error downloading file" - continue - fi - - remotePath=`echo $jsonAns | sed -e 's/.*"path": "\([^"]*\)".*/\1/' -e 's@\\\\/@/@g'` - #echo $remotePath - outFileName=`echo $remotePath | sed 's@.*/\([^/]*\)@\1@'` - #echo $outFileName - host=`echo $jsonAns | sed 's/.*"hosts": \[ "\([^"]*\)".*/\1/'` - #echo $host - linkLine="https://$host$remotePath" - #echo $linkLine - - # process line - localFile="$outDir/$outFileName" - # add the epub extension to kepub files - if echo "$localFile" | grep -Eq '\.kepub$' - then - localFile="$localFile.epub" - fi - $KC_HOME/getRemoteFile.sh "$linkLine" "$localFile" - if [ $? -ne 0 ] ; then - echo "Having problems contacting pCloud. Try again in a couple of minutes." - exit - fi -done - -if [ "$foundOldWay" == false ] ; then - echo "No files found using the old method, trying new method for pCloud." - baseURLWithSlash=$baseURL - baseURLWithSlash="${baseURLWithSlash%/}/" - $CURL -k -L --silent "$baseURL" | - ##get files with 3 or 4 characters extension - grep -Eo '"name": .+",$' | - ##Replace , - sed -E 's/"name": "(.+)",$/\1/' | - while read name - do - if ! echo "$name" | grep -qE '.+\..{3,4}$'; then - echo "Does not seem like a file so skipping: "$name - continue - fi - echo "Processing: "$name - linkLine=$baseURLWithSlash$name - localFile="$outDir/$outFileName" - $KC_HOME/getRemoteFile.sh "$linkLine" "$localFile" - outFileName=`echo $name | sed 's@.*/\([^/]*\)@\1@'` - if [ $? -ne 0 ] ; then - echo "Having problems contacting pCloud. Try again in a couple of minutes." - exit - fi - done -fi \ No newline at end of file diff --git a/src/usr/local/kobocloud/kobocloudrc.tmpl b/src/usr/local/kobocloud/kobocloudrc.tmpl index c3a96cd..9d375fc 100644 --- a/src/usr/local/kobocloud/kobocloudrc.tmpl +++ b/src/usr/local/kobocloud/kobocloudrc.tmpl @@ -1,4 +1,8 @@ -# Add your URLs to this file +# Add your sources by: +# Creating a rclone config file and copying it to this directory. +# (Detailed instructions https://rclone.org/remote_setup/#configuring-by-copying-the-config-file) +# Then, add each remote:folder/on/remote pair on each line. + # Remove the # from the following line to uninstall KoboCloud #UNINSTALL # Remove the # from the following line to delete files when they are no longer on the remote server diff --git a/src/usr/local/kobocloud/udev_mount.sh b/src/usr/local/kobocloud/udev_mount.sh index 96774b2..b037710 100755 --- a/src/usr/local/kobocloud/udev_mount.sh +++ b/src/usr/local/kobocloud/udev_mount.sh @@ -11,7 +11,7 @@ if [ ! -e $UserConfig ]; then if [ -e $ConfigFile ]; then cp $ConfigFile $UserConfig else - echo "# Add your URLs to this file" > $UserConfig + echo "# Add your rclone remote:folder/on/remote pairs to this file" > $UserConfig echo "# Remove the # from the following line to uninstall KoboCloud" >> $UserConfig echo "#UNINSTALL" >> $UserConfig fi