<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Soul Of Free Loop &#187; gett-cli</title>
	<atom:link href="https://zohead.com/archives/tag/gett-cli/feed" rel="self" type="application/rss+xml" />
	<link>https://zohead.com</link>
	<description>Uranus Zhou&#039;s Blog</description>
	<lastBuildDate>Sat, 19 Jul 2025 15:42:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>Arukas容器使用ge.tt替代Endpoint域名</title>
		<link>https://zohead.com/archives/arukas-ge-tt/</link>
		<comments>https://zohead.com/archives/arukas-ge-tt/#comments</comments>
		<pubDate>Sat, 06 May 2017 03:52:51 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Arukas]]></category>
		<category><![CDATA[Endpoint]]></category>
		<category><![CDATA[ge.tt]]></category>
		<category><![CDATA[gett-cli]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[Shadowsocks]]></category>
		<category><![CDATA[ShadowsocksR]]></category>
		<category><![CDATA[容器]]></category>

		<guid isPermaLink="false">https://zohead.com/?p=1437</guid>
		<description><![CDATA[ge.tt 与 Endpoint 前面写了一篇介绍日本 Arukas 樱花容器及使用其 Endpoint 域名的文章，目前我在 Arukas 上面跑了一个 Shadowsocks 容器用于路由器自动爬墙。不过还是发现如果 Arukas 容器的开放端口里开启了 UDP 端口（给 OpenWRT 路由器上的 ss-tunnel 用于转发解析被封锁的域名），这种情况下 Arukas 的 Endpoint 地址就基本没办法正常访问了。文章中我写的 OpenWRT 下自动获取 Arukas 容器 Shadowsocks 配置的脚本也经常出错，用起来还是不太方便。 刚好之前为了给其他人分享文件，我还写了一 [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2 id="gett-and-endpoint">ge.tt 与 Endpoint</h2>
<p>前面写了一篇介绍日本 <a href="https://zohead.com/archives/arukas-container/">Arukas 樱花容器</a>及使用其 Endpoint 域名的文章，目前我在 Arukas 上面跑了一个 Shadowsocks 容器用于路由器自动爬墙。不过还是发现如果 Arukas 容器的开放端口里开启了 UDP 端口（给 OpenWRT 路由器上的 <code>ss-tunnel</code> 用于转发解析被封锁的域名），这种情况下 Arukas 的 Endpoint 地址就基本没办法正常访问了。文章中我写的 OpenWRT 下自动获取 Arukas 容器 Shadowsocks 配置的脚本也经常出错，用起来还是不太方便。</p>
<p>刚好之前为了给其他人分享文件，我还写了一篇介绍 <a href="https://zohead.com/archives/ge-tt-cli-api/">ge.tt 文件分享 API</a> 的文章，就想到既然 Endpoint 地址访问容易出错，那可以在 Arukas Shadowsocks 容器里使用 ge.tt 的 Python CLI 将容器的当前地址和外部端口配置文件上传到指定的 ge.tt 分享地址，这样 OpenWRT 系统里也能很方便地通过分享地址更新配置文件了。</p>
<h2 id="arukas-container-mod">Arukas 容器修改</h2>
<p>这里的 Arukas 容器系统我使用的还是最新 baseimage 系统，增加了 <code>shadowsocks-libev</code> 服务器程序，并将 <code>gett-cli</code> 工具集成到 baseimage 系统，然后将 <code>/etc/my_init.d/01_start_ss_ssh.sh</code> 启动脚本修改为：</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash

# Enable SSH
rm -f /etc/service/sshd/down
/etc/my_init.d/00_regen_ssh_host_keys.sh
touch /etc/service/sshd/down

# Setup SSH key
if [ &quot;x$SSH_AUTHORIZED_KEYS&quot; = &quot;x&quot; ]; then
	/usr/sbin/enable_insecure_key
else
	mkdir ~/.ssh
	echo &quot;$SSH_AUTHORIZED_KEYS&quot; | sed 's/\\n/\n/g' &gt; ~/.ssh/authorized_keys
	chmod 400 ~/.ssh/authorized_keys
fi

# Start web server
env | grep -E '^MARATHON_HOST=|MARATHON_PORT_' &gt; /home/wwwroot/default/marathon.conf
if [ &quot;x$MARATHON_HOST&quot; != &quot;x&quot; ]; then
	getent hosts $MARATHON_HOST | awk '{print &quot;MARATHON_HOST_IP=&quot;$1; exit;}' &gt;&gt; /home/wwwroot/default/marathon.conf
fi

start-stop-daemon -S -b -n tmp-httpd -d /home/wwwroot/default -x /usr/bin/python3 -- -m http.server 80

# Start ShadowSocks
env | grep '^SHADOWSOCKS_CFGS_' | awk -F '=' '{print $1;}' | while read T_NAME; do
	SS_NAME=&quot;${T_NAME:17}&quot;
	echo &quot;${!T_NAME}&quot; &gt; /etc/shadowsocks-libev/${SS_NAME}.json
	start-stop-daemon -n ss-$SS_NAME -x /usr/bin/ss-server -b -S -- -c /etc/shadowsocks-libev/${SS_NAME}.json -u --fast-open
done

if [ &quot;x$GETT_TOKEN&quot; != &quot;x&quot; ]; then
	if [ &quot;x$HOME&quot; = &quot;x&quot; ]; then
		export HOME=&quot;/root&quot;
	fi
	echo -n &quot;$GETT_TOKEN&quot; &gt; ~/.gett-token
	if [ &quot;x$GETT_SHARE_NAME&quot; != &quot;x&quot; ]; then
		python3 /usr/local/gett/uploader.py -l http://ge.tt/$GETT_SHARE_NAME | awk '{if (substr($5,1,13)==&quot;http://ge.tt/&quot;) {print $5;}}' | xargs python3 /usr/local/gett/uploader.py --delete
		python3 /usr/local/gett/uploader.py -s http://ge.tt/$GETT_SHARE_NAME /home/wwwroot/default/marathon.conf
	fi
fi

exec /usr/sbin/sshd -D -e -u 0
</pre>
<p>这里增加了两个 ge.tt 文件分享服务相关的环境变量，通过 Docker 容器的 ENV 环境变量指定：</p>
<ul>
<li><code>GETT_TOKEN</code> <br />
在某台设备上使用 <code>gett-cli</code> 工具登录成功之后就能看到 <code>~/.gett-token</code> 文件中的 Refresh Token 内容；</li>
<li><code>GETT_SHARE_NAME</code> <br />
预先创建好固定的 ge.tt 分享名（例如：<code>8D95lij2</code>），可以在 ge.tt 网页中上传文件创建，也可以用 <code>gett-cli</code> 工具创建。</li>
</ul>
<p>如果容器的 ENV 列表里有这两个环境变量，启动脚本会自动将 Arukas 容器的当前地址和外部端口配置文件 <code>marathon.conf</code> 上传到指定的 ge.tt 分享地址。</p>
<h2 id="use-shadowsocks-container">使用 Shadowsocks 容器</h2>
<p>容器的 <code>CMD</code> 指令值以及其它 SSH 公钥和 Shadowsocks 服务器 JSON 配置文件环境变量与 <a href="https://zohead.com/archives/arukas-container/">Arukas 容器</a>文章中介绍的相同，可以根据需要自行配置。</p>
<p>我修改后的 Arukas 上支持 ge.tt 并适用于 baseimage 系统的 Shadowsocks 服务器安装包可以从这里下载：</p>
<p><a href="https://zohead.com/downloads/arukas-baseimage-xenial-ss.tar.gz">https://zohead.com/downloads/arukas-baseimage-xenial-ss.tar.gz</a></p>
<p>另外我还制作了一个 ShadowsocksR 服务器安装包，有需要的朋友可以下载测试看看，由于 baseimage 系统已经自带了 Python 3 环境，因此 ShadowsocksR 服务器安装包体积也要小一些：</p>
<p><a href="https://zohead.com/downloads/arukas-baseimage-xenial-ssr.tar.gz">https://zohead.com/downloads/arukas-baseimage-xenial-ssr.tar.gz</a></p>
<p>对于容器 ENV 列表中以 <code>SHADOWSOCKS_CFGS_</code> 开头的变量，启动脚本会自动在 <code>/etc/shadowsocks-libev</code> 目录（对于 ShadowsocksR 是 <code>/etc/shadowsocks</code> 目录）下生成 Shadowsocks 或 ShadowsocksR 服务器配置文件，配置文件内容就是该 JSON 格式变量的值。</p>
<p>例如我的 Arukas 容器配置中的 ShadowsocksR 环境变量：</p>
<pre class="brush: bash; title: ; notranslate">
SHADOWSOCKS_CFGS_xxx = { &quot;server&quot;:&quot;0.0.0.0&quot;, &quot;server_port&quot;:8113, &quot;local_port&quot;:1080, &quot;password&quot;:&quot;ssr-pass&quot;, &quot;timeout&quot;:30, &quot;method&quot;:&quot;aes-128-ctr&quot;, &quot;protocol&quot; : &quot;auth_aes128_md5&quot;, &quot;obfs&quot; : &quot;http_simple&quot; }
</pre>
<p>当然对于 ShadowsocksR 容器也需要相应地将 <code>CMD</code> 启动指令改为：</p>
<pre class="brush: bash; title: ; notranslate">
/sbin/my_init -- sh -c 'curl -o /arukas-baseimage-xenial-ssr.tar.gz https://zohead.com/downloads/arukas-baseimage-xenial-ssr.tar.gz &amp;&amp; tar -C / -xzf /arukas-baseimage-xenial-ssr.tar.gz &amp;&amp; /etc/my_init.d/01_start_ss_ssh.sh'
</pre>
<h2 id="openwrt-shadowsocks-script">OpenWRT 自动更新配置脚本</h2>
<p>为了能支持从 ge.tt 分享地址下载更新 Shadowsocks 配置，我对 OpenWRT 路由器上的 <code>arukas-ss.sh</code> 脚本也做了修改：</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh
ARUKAS_ENDPOINT=&quot;&quot;
GETT_SHRNAME=&quot;&quot;

[ $# -ge 2 ] || exit 1

[ -f /tmp/.marathon.conf ] &amp;&amp; mv /tmp/.marathon.conf /tmp/.marathon.conf.bak

IND=0
while [ $IND -lt 5 ]; do
	let IND++
	[ -f /tmp/.marathon.conf ] &amp;&amp; rm -f /tmp/.marathon.conf
	if [ &quot;x$GETT_SHRNAME&quot; != &quot;x&quot; ]; then
		T_FILEID=`curl -s -k -f http://api.ge.tt/1/shares/$GETT_SHRNAME | sed -e 's/^.*&quot;fileid&quot;[^:]*:[^&quot;]*&quot;//' -e 's/&quot;.*$//'`
		if [ &quot;x$T_FILEID&quot; != &quot;x&quot; ]; then
			curl -s -k -f -o /tmp/.marathon.conf -L -e &quot;http://ge.tt/$GETT_SHRNAME&quot; &quot;http://api.ge.tt/1/files/$GETT_SHRNAME/$T_FILEID/blob?download&quot;
			[ $? -eq 0 ] &amp;&amp; break
		fi
	fi
	curl -s -k -f -o /tmp/.marathon.conf https://$ARUKAS_ENDPOINT.arukascloud.io/marathon.conf
	[ $? -eq 0 ] &amp;&amp; break
	sleep 1
done

[ -s /tmp/.marathon.conf ] || exit 1
echo &quot;Fetch server config after $IND tries.&quot;

if [ -f /tmp/.marathon.conf.bak ]; then
	cmp -s /tmp/.marathon.conf /tmp/.marathon.conf.bak
	if [ $? -eq 0 ]; then
		rm -f /tmp/.marathon.conf
		exit 0
	fi
fi

. /tmp/.marathon.conf 2&gt;/dev/null
if [ &quot;x$MARATHON_HOST&quot; = &quot;x&quot; ]; then
	rm -f /tmp/.marathon.conf
	exit 1
fi

while [ $# -gt 1 ]; do
	CMD=&quot;echo \${MARATHON_PORT_$2}&quot;
	SS_PORT=`eval $CMD`

	if [ -f $1 -a &quot;x$SS_PORT&quot; != &quot;x&quot; ]; then
		if [ &quot;x$MARATHON_HOST_IP&quot; != &quot;x&quot; ]; then
			MARATHON_HOST=&quot;$MARATHON_HOST_IP&quot;
		fi
		sed -i -e 's/&quot;server&quot;[^:]*:[^,]*,/&quot;server&quot; : &quot;'$MARATHON_HOST'&quot;,/' -e 's/&quot;server_port&quot;[^:]*:[^,]*,/&quot;server_port&quot; : &quot;'$SS_PORT'&quot;,/' $1
	fi
	shift
	shift
done

if [ &quot;x$RESTART_SHADOWSOCKS&quot; != &quot;xno&quot; ]; then
	/etc/init.d/shadowsocks restart
fi
</pre>
<p>使用之前请先根据需要修改脚本最上面的 <code>ARUKAS_ENDPOINT</code> 和 <code>GETT_SHRNAME</code> 变量（一般指定其中一个即可），分别为 Arukas 容器的 Endpoint 名和 ge.tt 分享名，脚本会分别尝试通过 ge.tt 分享地址和 Arukas Endpoint 地址下载容器的 <code>marathon.conf</code> 配置文件。</p>
<p>为了使用简单性考虑，修改后的 <code>arukas-ss.sh</code> 脚本是直接通过 <code>/etc/init.d/shadowsocks</code> 服务脚本重启 OpenWRT 上的 Shadowsocks 客户端程序。该脚本的使用方法也请参考我之前写的介绍 Arukas 容器及 Endpoint 的文章。</p>
<p>最后祝大家心中无墙，玩的开心 ^_^。</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/arukas-ge-tt/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ge.tt文件分享服务CLI及API的问题</title>
		<link>https://zohead.com/archives/ge-tt-cli-api/</link>
		<comments>https://zohead.com/archives/ge-tt-cli-api/#comments</comments>
		<pubDate>Mon, 17 Apr 2017 18:16:13 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[ge.tt]]></category>
		<category><![CDATA[gett-cli]]></category>
		<category><![CDATA[分享]]></category>

		<guid isPermaLink="false">https://zohead.com/?p=1421</guid>
		<description><![CDATA[关于 ge.tt 最近我一直在寻找支持直链形式的文件分享服务： 支持通过 cURL 或者公开 API 上传文件生成分享地址； 用户可以通过 wget、cURL 等程序直接下载文件； 上传者后续可以更新文件并保持分享地址不变； 国内的普通用户可以正常访问下载分享的文件。 如果使用 Dropbox、Google Drive 应该也可以实现前面几个需求，但这两个网盘的最大问题在于国内难以描述的墙，而且上传下载还是稍微有点复杂。 以前我使用过 DriveHQ 服务，免费用户支持通过 FTP 方式上传文件（付费用户还支持通过 WebDAV 上传），上传到 Web 分享目录的文件可以直接通过 HTTP 下 [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2 id="about-gett">关于 ge.tt</h2>
<p>最近我一直在寻找支持直链形式的文件分享服务：</p>
<ul>
<li>支持通过 cURL 或者公开 API 上传文件生成分享地址；</li>
<li>用户可以通过 wget、cURL 等程序直接下载文件；</li>
<li>上传者后续可以更新文件并保持分享地址不变；</li>
<li>国内的普通用户可以正常访问下载分享的文件。</li>
</ul>
<p>如果使用 Dropbox、Google Drive 应该也可以实现前面几个需求，但这两个网盘的最大问题在于国内难以描述的墙，而且上传下载还是稍微有点复杂。</p>
<p>以前我使用过 <a href="https://www.drivehq.com/" target="_blank">DriveHQ</a> 服务，免费用户支持通过 FTP 方式上传文件（付费用户还支持通过 WebDAV 上传），上传到 Web 分享目录的文件可以直接通过 HTTP 下载，这样也算能达到我的要求了，只是自动处理 FTP 上传覆盖要稍微麻烦点。</p>
<p>目前我使用的是 <a href="http://ge.tt/" target="_blank">ge.tt</a> 文件分享服务，相对 DriveHQ 来说其优势在于 ge.tt 开放了 API，而且也有第三方写的 Python / Perl / Java 等各种形式的文件管理工具。虽然 ge.tt 免费帐户只有 2GB 的存储空间，但仍然已经有 500 多万的用户分享了近 5000 万份文件，拿来分享一些小文件或者程序也是很方便的了。</p>
<p>ge.tt 提供了 REST 和 Live API，重点可以关注其 REST API（不过 ge.tt 官网的 API 说明文档暂时无法访问）：</p>
<p><a href="http://ge.tt/developers/overview" target="_blank">http://ge.tt/developers/overview</a></p>
<p>ge.tt 推荐在客户端上使用 gett-cli 工具来管理文件和分享，同样可以参考其官网说明：</p>
<p><a href="http://ge.tt/tools" target="_blank">http://ge.tt/tools</a></p>
<h2 id="gett-cli-problem">gett-cli 的问题</h2>
<p>gett-cli 工具基于 Python 3 实现，其 Bitbucket 项目主页为：</p>
<p><a href="https://bitbucket.org/mickael9/gett-cli/overview" target="_blank">https://bitbucket.org/mickael9/gett-cli/overview</a></p>
<p>查看项目说明显示该工具看起来也很简单，安装之后通过 <code>gett</code> 命令就可以管理了。<code>gett</code> 命令默认提供了上传文件、列表分享、删除分享、删除分享中的文件（一个分享地址支持包含多个文件）、搜索分享或文件的功能。</p>
<p>只是 gett-cli 在一开始登录的时候就碰到了问题，输入用户和密码之后直接登录失败：</p>
<pre class="brush: bash; title: ; notranslate">
(trusty)zzm@localhost:~/Downloads$ gett
Please enter your Ge.tt email: xxx@gmail.com
Please enter your Ge.tt password: 
Traceback (most recent call last):
  File &quot;/usr/local/bin/gett&quot;, line 11, in &lt;module&gt;
    load_entry_point('gett-cli==0.2.3', 'console_scripts', 'gett')()
  File &quot;/usr/local/lib/python3.4/dist-packages/gett_cli-0.2.3-py3.4.egg/gett/uploader.py&quot;, line 96, in entry_point
  File &quot;/usr/local/lib/python3.4/dist-packages/gett_cli-0.2.3-py3.4.egg/gett/uploader.py&quot;, line 198, in main
  File &quot;/usr/local/lib/python3.4/dist-packages/gett_cli-0.2.3-py3.4.egg/gett/gett.py&quot;, line 122, in login_auth
  File &quot;/usr/local/lib/python3.4/dist-packages/gett_cli-0.2.3-py3.4.egg/gett/gett.py&quot;, line 103, in _load
KeyError: 'accesstoken'
</pre>
<p>我在参考 ge.tt 的 REST API 说明之后使用 cURL 模拟登录请求，ge.tt 服务器也会返回 <code>Wrong credentials</code> 错误：</p>
<pre class="brush: bash; title: ; notranslate">
(trusty)zzm@localhost:~/Downloads$ curl -i -X POST --data '{&quot;email&quot;:&quot;xxx@gmail.com&quot;,&quot;password&quot;:&quot;test-pass&quot;}' http://
open.ge.tt/1/users/login
HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=utf-8
Date: Wed, 05 Apr 2017 18:11:11 GMT
ETag: W/&quot;71-xxx+xxx&quot;
set-cookie: sails.sid=s%3Axxx-xxx%2FkOnG%2Bxxx%2Bxxx; Path=/; HttpOnly
Vary: X-HTTP-Method-Override, Accept-Encoding
X-Powered-By: Sails &lt;sailsjs.org&gt;
Content-Length: 113
Connection: keep-alive

{&quot;message&quot;:&quot;Wrong credentials&quot;,&quot;body&quot;:{&quot;err&quot;:&quot;Missing credentials&quot;},&quot;login&quot;:0,&quot;reason&quot;:{&quot;error&quot;:&quot;access denied&quot;}}
</pre>
<p>经过调试我才发现 ge.tt 的 REST API 请求中必须增加 <code>Content-Type: application/json;charset=UTF-8</code> 头才能正常返回数据。</p>
<p>修改 gett-cli 工具 Python 代码之后，现在 <code>gett</code> 命令可以正常返回用户使用的空间了：</p>
<pre class="brush: bash; title: ; notranslate">
(trusty)zzm@localhost:~/Downloads$ gett
Please enter your Ge.tt email: xxx@gmail.com
Please enter your Ge.tt password: 
Do you wish to store the session token? (y/n): y
Storage used: 232.81 KB out of 2.00 GB (0.0%)
</pre>
<p>登录成功之后 gett-cli 工具默认会将 Refresh Token 保存在用户主目录的 <code>.gett-token</code> 文件中：</p>
<pre class="brush: bash; title: ; notranslate">
root@ee9055d6b11f:~# cat .gett-token
r.0.user-25YKSbxxxxxxx-..xxxxxxx
</pre>
<p>这样后面再使用 gett-cli 工具就不用重复输入用户名和密码登录了。</p>
<h2 id="mod-gett-cli">修改 gett-cli</h2>
<p>另外我还发现 gett-cli 工具存在由于缺少文件大小参数导致上传的文件不正确等问题，为此我专门修改了 gett-cli 代码以解决登录和上传的问题。由于生成的 <code>gett-cli.patch</code> 补丁文件内容有点长这里就不贴出来了，有需要的话可以从下面的 Pastebin 地址下载：</p>
<p><a href="http://pastebin.com/raw/0siCtqkW" target="_blank">http://pastebin.com/raw/0siCtqkW</a></p>
<p>有动手能力的朋友们可以自行检出 Bitbucket 上的 gett-cli 版本库进行修改编译安装。</p>
<p>如果嫌编译麻烦也可以直接修改替换已经安装好的 gett-cli 工具 egg 文件，以我使用的 Ubuntu 系统上的 Python 3.4 为例，大概步骤如下（中间直接使用 <code>patch</code> 命令打补丁）：</p>
<pre class="brush: bash; title: ; notranslate">
(trusty)zzm@localhost:~/Downloads$ cp /usr/local/lib/python3.4/dist-packages/gett_cli-0.2.3-py3.4.egg .
(trusty)zzm@localhost:~/Downloads$ sudo unzip gett_cli-0.2.3-py3.4.egg &amp;&amp; rm -f gett_cli-0.2.3-py3.4.egg
Archive:  gett_cli-0.2.3-py3.4.egg
  inflating: EGG-INFO/zip-safe
  inflating: EGG-INFO/top_level.txt
  inflating: EGG-INFO/entry_points.txt
  inflating: EGG-INFO/dependency_links.txt
  inflating: EGG-INFO/SOURCES.txt
  inflating: EGG-INFO/PKG-INFO
  inflating: gett/uploader.py
  inflating: gett/gett.py
  inflating: gett/__init__.py
  inflating: gett/__pycache__/uploader.cpython-34.pyc
  inflating: gett/__pycache__/gett.cpython-34.pyc
  inflating: gett/__pycache__/__init__.cpython-34.pyc
(trusty)zzm@localhost:~/Downloads$ sudo patch -p2 &lt; gett-cli.patch
(trusty)zzm@localhost:~/Downloads$ sudo py3compile gett/gett.py gett/uploader.py
(trusty)zzm@localhost:~/Downloads$ sudo zip -r gett_cli-0.2.3-py3.4.egg EGG-INFO gett
  adding: EGG-INFO/ (stored 0%)
  adding: EGG-INFO/PKG-INFO (deflated 26%)
  adding: EGG-INFO/entry_points.txt (deflated 2%)
  adding: EGG-INFO/top_level.txt (stored 0%)
  adding: EGG-INFO/SOURCES.txt (deflated 48%)
  adding: EGG-INFO/dependency_links.txt (stored 0%)
  adding: EGG-INFO/zip-safe (stored 0%)
  adding: gett/ (stored 0%)
  adding: gett/uploader.py (deflated 68%)
  adding: gett/__pycache__/ (stored 0%)
  adding: gett/__pycache__/__init__.cpython-34.pyc (deflated 21%)
  adding: gett/__pycache__/gett.cpython-34.pyc (deflated 57%)
  adding: gett/__pycache__/uploader.cpython-34.pyc (deflated 48%)
  adding: gett/__init__.py (stored 0%)
  adding: gett/gett.py (deflated 71%)
(trusty)zzm@localhost:~/Downloads$ sudo mv gett_cli-0.2.3-py3.4.egg /usr/local/lib/python3.4/dist-packages/gett_cli-0.2.3-py3.4.egg
</pre>
<p>当然如果你不想在系统中安装 gett-cli 也可以直接下载使用我修改好的 gett 工具，解压缩之后运行其中的 <code>uploader.py</code> 程序即可（需要 Python 3 环境）：</p>
<p><a href="https://zohead.com/downloads/gett-cli-0.2.3.tar.gz">https://zohead.com/downloads/gett-cli-0.2.3.tar.gz</a></p>
<h2 id="use-gett-cli">使用 gett-cli 工具</h2>
<p>登录之后使用 gett-cli 工具上传文件非常简单，默认上传文件时都是创建新的分享，上传多个文件则直接附加多个文件参数：</p>
<pre class="brush: bash; title: ; notranslate">
(trusty)zzm@localhost:~/Downloads$ gett gett-cli-0.2.3.tar.gz
Creating file(s)...
--------------------------------------------------------------------------------
Share: Untitled (1 file(s)) [http://ge.tt/8D95lij2]
--------------------------------------------------------------------------------
 - gett-cli-0.2.3.tar.gz           6.54 KB  http://ge.tt/8D95lij2/v/0  remote

gett-cli-0.2.3.tar.gz  (  1/1) [########################################] 100 %

Storage used: 194.00  B out of 2.00 GB (0.0%)
</pre>
<p>上面结果中的 <code>http://ge.tt/8D95lij2</code> 就是新创建的文件分享地址，<code>http://ge.tt/8D95lij2/v/0</code> 则是该分享中某个文件的地址（<code>0</code> 是分享下的文件 ID，如果上传多个文件就会有 <code>v/1</code>、<code>v/2</code> 之类的文件地址）。</p>
<p>如果需要删除创建的分享可以运行：</p>
<pre class="brush: bash; title: ; notranslate">
(trusty)zzm@localhost:~/Downloads$ gett --delete http://ge.tt/8D95lij2
Deleted share: Untitled [http://ge.tt/8D95lij2]

Storage used: 6.74 KB out of 2.00 GB (0.0%)
</pre>
<p>用户如果需要下载分享中的文件那就更方便了，不需要 gett-cli 工具，直接一条 cURL 命令下载即可（替换命令中的分享地址和文件 ID）：</p>
<pre class="brush: bash; title: ; notranslate">
(trusty)zzm@localhost:~/Downloads$ curl -k -o gett-cli-0.2.3.tar.gz -L -e &quot;http://ge.tt/8D95lij2&quot; &quot;http://api.ge.tt/1/files/8D95lij2/0/blob?download&quot;
</pre>
<h2 id="postscript">后记</h2>
<p>ge.tt 文件分享服务还存在一些小问题，比如某个分享中已经上传的文件目前还无法直接以相同的文件 ID 进行覆盖替换（例如上面例子中的 <code>http://ge.tt/8D95lij2/v/0</code>），只能删除文件再上传新文件到该分享，新上传的文件的 ID 只能递增，不能保持原来的文件 ID（例如删除之后新上传的文件 ID 可能是 <code>http://ge.tt/8D95lij2/v/3</code>）。</p>
<p>结合这段时间我的使用感觉来看，ge.tt 用于分享小文件还算比较方便的，很适合一些需要通过工具或命令自动上传下载文件的场合。最后如果文章中有任何问题，还请提出指正，祝大家玩的开心。</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/ge-tt-cli-api/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
