ユーザ用ツール

サイト用ツール


サイドバー

最新の10件
一覧
linux:yandex.disk

Yandex.Disk

WebDav

以前は davs://webdav.yandex.com/ でアクセスできていたと思うのだけど今うまく行かない?(2020-03-06)

英語helpにはWebDavの記述があるが,ロシア語版では消えているので無くなったのかもしれない.

公式 cli client

Debian/Ubuntuへの導入

source.listに登録して導入

$ echo "deb http://repo.yandex.ru/yandex-disk/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/yandex-disk.list > /dev/null && wget http://repo.yandex.ru/yandex-disk/YANDEX-DISK-KEY.GPG -O- | sudo apt-key add - && sudo apt-get update && sudo apt-get install -y yandex-disk

初回setup

いくつか質問を聞かれる.

  • Would you like to use a proxy server? [y/N]:
    • proxy serverを使うか?
  • Enter username:
    • Yandexユーザ名
  • Enter password:
    • Yandexパスワード(入力した内容は表示されない)
  • Enter path to Yandex.Disk folder (Leave empty to use default folder '/home/matoken/Yandex.Disk'):
    • Yandex.Diskの同期フォルダ.既定値( ~/Yandex.Disk )で良ければそのまま
  • Would you like Yandex.Disk to launch on startup? [Y/n]:
    • 起動時に自動起動するか
$ yandex-disk setup
Would you like to use a proxy server? [y/N]: 
Log in
If you don't have a Yandex account yet, get one at https://passport.yandex.com/passport?mode=register

Enter username: matoken
Enter password: 
Token saved to /home/matoken/.config/yandex-disk/passwd
Configure Yandex.Disk
Enter path to Yandex.Disk folder (Leave empty to use default folder '/home/matoken/Yandex.Disk'): 
Would you like Yandex.Disk to launch on startup? [Y/n]: 
Starting daemon process...Done

daemonが起動している

$ ps aux|grep yandex
matoken  2685409  0.4  0.0 1155992 15644 ?       Ssl  00:54   0:00 /usr/bin/yandex-disk --tag="1 8 9 12 15 16 19" --proxy="no" --no-daemon="true"
 --dir="/home/matoken/Yandex.Disk" --auth="/home/matoken/.config/yandex-disk/passwd"

同期されているのを確認する

$ ls -A ~/Yandex.Disk/
 .sync                                                      RaspberryPi
 Azure-r.odt                                               'Social networks'
'Camera Uploads'                                           'SoftRAID 構築時の監視設定.mkd.odt'
  :

statusサブコマンドで同期状況などの確認

$ yandex-disk status
Sync progress: 9.20 MB/ 10.91 GB (0 %)
Synchronization core status: busy
Path to Yandex.Disk directory: '/home/matoken/Yandex.Disk'
        Total: 45 GB
        Used: 10.90 GB
        Available: 34.10 GB
        Max file size: 50 GB
        Trash size: 0 B

Last synchronized items:
        file: 'Camera Uploads/2017-04-05 01-21-45.PNG'
        file: 'Camera Uploads/2017-09-30 13-18-44.PNG'
        file: 'Camera Uploads/2017-04-18 03-03-30.PNG'
        file: 'Camera Uploads/2017-10-03 05-22-26.PNG'
        file: 'Camera Uploads/2017-04-08 01-14-11.PNG'
        file: 'Camera Uploads/2016-06-21 22-22-35.PNG'
        file: 'Camera Uploads/2017-09-23 17-16-48.PNG'
        file: 'Camera Uploads/2016-03-02 18-30-01.PNG'
        file: 'Camera Uploads/2017-03-15 13-02-40.PNG'
        file: 'Camera Uploads/2016-11-06 15-03-09.JPG'

同期除外ディレクトリの指定

$ yandex-disk sync --exclude-dirs=dir1,dir1 として除外ディレクトリを指定できるが,これだと毎回指定する必要がある.設定ファイルの exclude-dirs= にも書ける.このときのディレクトリは Yandex.Disk の / 以降から書く.(ローカルの ~/Yandex.Disk は書かない)

$ yandex-disk stop #daemonを停止
Daemon stopped.
$ # 同期除外ディレクトリ設定を追加
$ echo 'exclude-dirs="Camera Uploads,package,Downloads,package,Music,RaspberryPi,Social networks"' | tee -a ~/.config/yandex-disk/config.cfg
exclude-dirs="Camera Uploads,package,Downloads,package,Music,RaspberryPi,Social networks"
$ yandex-disk start #daemon開始
Starting daemon process...Done

指定したファイル,ディレクトリの公開リンクを取得する

PC上のPathでもYandex.Disk Root以降でのPathでも良さそう.

$ yandex-disk publish Sea.jpg
https://yadi.sk/i/_mdbSx6QBOzJbA
$ yandex-disk publish ~/Yandex.Disk/Sea.jpg
https://yadi.sk/i/_mdbSx6QBOzJbA

公開リンクの取り消し

上で作成した公開リンクにアクセスできるのを確認

$ w3m -dump_head https://yadi.sk/i/_mdbSx6QBOzJbA | grep HTTP/
HTTP/1.1 200 OK

unpublish サブコマンドで取り消しする

$ yandex-disk unpublish Sea.jpg
Complete unshare

アクセスできなくなっているのを確認

$ w3m -dump_head https://yadi.sk/i/_mdbSx6QBOzJbA | grep HTTP/
HTTP/1.1 404 Not Found

help

$ yandex-disk --help
Yandex.Disk 0.1.5.1039
Usage:
  yandex-disk start [OPTION]
  yandex-disk stop [OPTION]
  yandex-disk status [OPTION]
  yandex-disk sync [OPTION]
  yandex-disk token [-p, --password=PASSWORD] [OPTION] USERNAME [FILE]
  yandex-disk publish [OPTION] FILE
  yandex-disk unpublish FILE

Commands:
  start        start in daemon mode, performing synchronization. The current
               state of the daemon can be read from the file ".sync/status"
               in the sync directory.
  stop         stop running daemon.
  status       display status: sync state, errors,

recently synchronized files, total and remaining space quota.
  token        get OAuth token, encrypt and store it in specified file (by
               default - /.config/yandex-disk/passwd). If -p PASSWORD or
               --password PASSWORD options are not specified, password
               will be read from STDIN.
  sync         synchronize everything and exit (If daemon is started wait
               for full sync and exit.
  publish      make file/folder public, output public link to STDOUT.
               Object will be copied to the root of sync folder.
               To overwrite existing objects use
               the option --overwrite.
  unpublish    withdraw file from public access.
  setup        launch the setup wizard.

Options:
  --config=FILE, -c FILE
               read options from configuration file. Configuration
               file must contain lines in the form of name=value.
               Defaults to file ~/.config/yandex-disk/config.cfg.
  --dir=DIR, -d DIR
               path to Yandex.Disk directory.
  --auth=FILE, -a FILE
               read token from file. File must be prepared using
               token command. Defaults to file ~/.config/yandex-disk/passwd.
  --exclude-dirs=DIR1,DIR2,…
               do not synchronize specified directories.
  --read-only
               only download changed files from server,
               files changed locally, will be renamed to preserve
               modifications.
  --overwrite
               overwrite localy changed files in read-only mode.
  --no-daemon, -D
               launch daemon without returning management to console.
               To return management, daemon must be stopped,
               by launching the command yandex-disk stop in another console or
               by closing the current console.
  --version, -v
               display version information.
  --proxy=PARAM
             setup proxy. Allowable parameters:
                              auto - use system proxy settings. These are used by default.
                              no - do not use proxy.
                              protocol,address,port,login,password - set manually.
                              An example of setting proxy manually:
                              proxy=socks4,my.proxy.local,1080,login,password

man

$ man yandex-disk
yandex-disk(1)                                                       MISC                                                      yandex-disk(1)

NAME
       yandex-disk - Command line utility for Yandex.Disk (http://disk.yandex.com).

OVERVIEW
       yandex-disk start [OPTION]

       yandex-disk stop [OPTION]

       yandex-disk status [OPTION]

       yandex-disk sync [OPTION]

       yandex-disk token [-p, --password=PASSWORD] [OPTION] USERNAME [FILE]

       yandex-disk publish [OPTION] FILE

       yandex-disk unpublish FILE

DESCRIPTION
       The Yandex.Disk client console lets you:
       * synchronize files and folders with your Disk
       * get public links to files and folders
       * customize folder syncing

OPTIONS
       Commands:

              setup - Launch the setup wizard.

              start - Launch as daemon and start syncing folders. The current sync status is recorded in the file ".sync/status".

              stop - stop daemon.

              status - show daemon status: sync status, errors, recently synced files, disk space status.

              token  -  receive  OAuth token, encode and save it in a special file (by default - /.config/yandex-disk/passwd). If the options
              -p PASSWORD or --password PASSWORD are not shown, then the password must be entered from STDIN.

              sync - sync the folder and log out (if the daemon is running, wait for syncing to finish).

              publish - make the file/folder public and remove the link to STDOUT. The item will be copied to the sync folder. Use the option
              --overwrite to rewrite existing items.

              unpublish - removes public access to the file/folder.

       Options:

              --help, -h - displays help.

              --version, -v - displays information about the version.

              --config=FILE,  -c  FILE  - read options from the configuration file. The file should contain lines in the form name=value. The
              default file path ~/.config/yandex-disk/config.cfg.

              --dir=DIR, -d DIR - Yandex.Disk folder path.

              --auth=FILE, -a FILE - read token from file. The file should be prepared using the token command.  The  default  file  path  is
              ~/.config/yandex-disk/passwd.

              --exclude-dirs=DIR1,DIR2,...  - do not sync specified folders.

              --read-only - do not upload local changes to the server. Locally changed files will be renamed.

              --overwrite - overwrite locally changed files in read-only mode.

              --no-daemon,  -D  -  launch  daemon  without  returning management to console. To return management, daemon must be stopped, by
              launching the command yandex-disk stop in another console or by closing the current console.

              --proxy=PARAM - setup proxy. Allowable parameters:
              auto - use system proxy settings. These are used by default.
              no - do not use proxy.
              protocol,address,port,login,password - set manually.
              An example of setting proxy manually:
              proxy=socks4,my.proxy.local,1080,login,password

version 0.1.5.1039                                                   2019                                                      yandex-disk(1)

確認したバージョン

$ dpkg-query -W yandex-disk
yandex-disk     0.1.5.1039

rclone

rcloneもYandex.Diskに対応している

$ sudo apt install rclone
$ rclone authorize

nameはrcloneコマンド発行時に指定するので入力しやすいもののほうが良い

No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> yandex
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
Choose a number from below, or type in your own value
  :
29 / Webdav
   \ "webdav"
30 / Yandex Disk
   \ "yandex"
31 / http Connection
   \ "http"
32 / premiumize.me
   \ "premiumizeme"
Storage> 30

client_id,client_secret は “” のままでok

Yandex Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
Yandex Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>   

Y だとウェブブラウザ経由で認証を行う N は未検証(多分URLを別の端末で開いて認証後にトークンを入手して入力?)

Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> y

Root以下のファイルディレクトリリストを取得

$ rclone ls yandex:

コメント

コメントを入力. Wiki文法が有効です:
   ___  __  __  ____    ___  ______
  / _ ) \ \/ / / __ \  / _ \/_  __/
 / _  |  \  / / /_/ / / , _/ / /   
/____/   /_/  \____/ /_/|_| /_/
 
linux/yandex.disk.txt · 最終更新: 2020/03/13 16:42 by matoken