Browse code

Saving attachments

Julio Biason authored on 17/05/2019 09:07:37
Showing 3 changed files

... ...
@@ -24,6 +24,16 @@ name = "ascii"
24 24
 version = "0.9.1"
25 25
 source = "registry+https://github.com/rust-lang/crates.io-index"
26 26
 
27
+[[package]]
28
+name = "atty"
29
+version = "0.2.11"
30
+source = "registry+https://github.com/rust-lang/crates.io-index"
31
+dependencies = [
32
+ "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
33
+ "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
34
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
35
+]
36
+
27 37
 [[package]]
28 38
 name = "autocfg"
29 39
 version = "0.1.2"
... ...
@@ -157,7 +167,7 @@ dependencies = [
157 167
 
158 168
 [[package]]
159 169
 name = "cookie"
160
-version = "0.11.1"
170
+version = "0.12.0"
161 171
 source = "registry+https://github.com/rust-lang/crates.io-index"
162 172
 dependencies = [
163 173
  "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
... ...
@@ -166,17 +176,15 @@ dependencies = [
166 176
 
167 177
 [[package]]
168 178
 name = "cookie_store"
169
-version = "0.5.1"
179
+version = "0.7.0"
170 180
 source = "registry+https://github.com/rust-lang/crates.io-index"
171 181
 dependencies = [
172
- "cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
182
+ "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
173 183
  "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
174
- "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
175 184
  "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
176 185
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
177 186
  "publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
178 187
  "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
179
- "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
180 188
  "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
181 189
  "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
182 190
  "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
... ...
@@ -267,7 +275,11 @@ name = "downfav"
267 275
 version = "0.1.0"
268 276
 dependencies = [
269 277
  "elefren 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
278
+ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
270 279
  "html2md 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
280
+ "hyper 0.12.28 (registry+https://github.com/rust-lang/crates.io-index)",
281
+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
282
+ "reqwest 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)",
271 283
 ]
272 284
 
273 285
 [[package]]
... ...
@@ -289,7 +301,7 @@ dependencies = [
289 301
  "doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
290 302
  "hyper-old-types 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
291 303
  "isolang 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
292
- "reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)",
304
+ "reqwest 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)",
293 305
  "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
294 306
  "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
295 307
  "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
... ...
@@ -310,6 +322,18 @@ dependencies = [
310 322
  "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
311 323
 ]
312 324
 
325
+[[package]]
326
+name = "env_logger"
327
+version = "0.6.1"
328
+source = "registry+https://github.com/rust-lang/crates.io-index"
329
+dependencies = [
330
+ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
331
+ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
332
+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
333
+ "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
334
+ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
335
+]
336
+
313 337
 [[package]]
314 338
 name = "error-chain"
315 339
 version = "0.12.0"
... ...
@@ -470,6 +494,14 @@ name = "httparse"
470 494
 version = "1.3.3"
471 495
 source = "registry+https://github.com/rust-lang/crates.io-index"
472 496
 
497
+[[package]]
498
+name = "humantime"
499
+version = "1.2.0"
500
+source = "registry+https://github.com/rust-lang/crates.io-index"
501
+dependencies = [
502
+ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
503
+]
504
+
473 505
 [[package]]
474 506
 name = "hyper"
475 507
 version = "0.12.28"
... ...
@@ -788,6 +820,11 @@ dependencies = [
788 820
  "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
789 821
 ]
790 822
 
823
+[[package]]
824
+name = "numtoa"
825
+version = "0.1.0"
826
+source = "registry+https://github.com/rust-lang/crates.io-index"
827
+
791 828
 [[package]]
792 829
 name = "openssl"
793 830
 version = "0.10.22"
... ...
@@ -925,6 +962,11 @@ dependencies = [
925 962
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
926 963
 ]
927 964
 
965
+[[package]]
966
+name = "quick-error"
967
+version = "1.2.2"
968
+source = "registry+https://github.com/rust-lang/crates.io-index"
969
+
928 970
 [[package]]
929 971
 name = "quote"
930 972
 version = "0.6.12"
... ...
@@ -1054,6 +1096,14 @@ name = "redox_syscall"
1054 1096
 version = "0.1.54"
1055 1097
 source = "registry+https://github.com/rust-lang/crates.io-index"
1056 1098
 
1099
+[[package]]
1100
+name = "redox_termios"
1101
+version = "0.1.1"
1102
+source = "registry+https://github.com/rust-lang/crates.io-index"
1103
+dependencies = [
1104
+ "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)",
1105
+]
1106
+
1057 1107
 [[package]]
1058 1108
 name = "regex"
1059 1109
 version = "1.1.6"
... ...
@@ -1084,13 +1134,13 @@ dependencies = [
1084 1134
 
1085 1135
 [[package]]
1086 1136
 name = "reqwest"
1087
-version = "0.9.16"
1137
+version = "0.9.17"
1088 1138
 source = "registry+https://github.com/rust-lang/crates.io-index"
1089 1139
 dependencies = [
1090 1140
  "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
1091 1141
  "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
1092
- "cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
1093
- "cookie_store 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
1142
+ "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
1143
+ "cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
1094 1144
  "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
1095 1145
  "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
1096 1146
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
... ...
@@ -1196,6 +1246,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1196 1246
 name = "serde"
1197 1247
 version = "1.0.91"
1198 1248
 source = "registry+https://github.com/rust-lang/crates.io-index"
1249
+dependencies = [
1250
+ "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
1251
+]
1199 1252
 
1200 1253
 [[package]]
1201 1254
 name = "serde_derive"
... ...
@@ -1368,6 +1421,25 @@ dependencies = [
1368 1421
  "utf-8 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
1369 1422
 ]
1370 1423
 
1424
+[[package]]
1425
+name = "termcolor"
1426
+version = "1.0.4"
1427
+source = "registry+https://github.com/rust-lang/crates.io-index"
1428
+dependencies = [
1429
+ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1430
+]
1431
+
1432
+[[package]]
1433
+name = "termion"
1434
+version = "1.5.2"
1435
+source = "registry+https://github.com/rust-lang/crates.io-index"
1436
+dependencies = [
1437
+ "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
1438
+ "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1439
+ "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)",
1440
+ "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1441
+]
1442
+
1371 1443
 [[package]]
1372 1444
 name = "thread_local"
1373 1445
 version = "0.3.6"
... ...
@@ -1679,6 +1751,15 @@ name = "winapi-x86_64-pc-windows-gnu"
1679 1751
 version = "0.4.0"
1680 1752
 source = "registry+https://github.com/rust-lang/crates.io-index"
1681 1753
 
1754
+[[package]]
1755
+name = "wincolor"
1756
+version = "1.0.1"
1757
+source = "registry+https://github.com/rust-lang/crates.io-index"
1758
+dependencies = [
1759
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
1760
+ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
1761
+]
1762
+
1682 1763
 [[package]]
1683 1764
 name = "ws2_32-sys"
1684 1765
 version = "0.2.1"
... ...
@@ -1693,6 +1774,7 @@ dependencies = [
1693 1774
 "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c"
1694 1775
 "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"
1695 1776
 "checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335"
1777
+"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
1696 1778
 "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
1697 1779
 "checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637"
1698 1780
 "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
... ...
@@ -1710,8 +1792,8 @@ dependencies = [
1710 1792
 "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
1711 1793
 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
1712 1794
 "checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680"
1713
-"checksum cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99be24cfcf40d56ed37fd11c2123be833959bbc5bddecb46e1c2e442e15fa3e0"
1714
-"checksum cookie_store 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b0d2f2ecb21dce00e2453268370312978af9b8024020c7a37ae2cc6dbbe64685"
1795
+"checksum cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5"
1796
+"checksum cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c"
1715 1797
 "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
1716 1798
 "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
1717 1799
 "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
... ...
@@ -1726,6 +1808,7 @@ dependencies = [
1726 1808
 "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b"
1727 1809
 "checksum elefren 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)" = "34f49632a0d50544fe2874ac59c0c36c79871269e58b491ed73c94ffe71d0568"
1728 1810
 "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed"
1811
+"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a"
1729 1812
 "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
1730 1813
 "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
1731 1814
 "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
... ...
@@ -1745,6 +1828,7 @@ dependencies = [
1745 1828
 "checksum html5ever 0.22.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c213fa6a618dc1da552f54f85cba74b05d8e883c92ec4e89067736938084c26e"
1746 1829
 "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a"
1747 1830
 "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83"
1831
+"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114"
1748 1832
 "checksum hyper 0.12.28 (registry+https://github.com/rust-lang/crates.io-index)" = "e8e4606fed1c162e3a63d408c07584429f49a4f34c7176cb6cbee60e78f2372c"
1749 1833
 "checksum hyper-old-types 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6896be51ecf3966c0fa14ff2da3233dbb9aef57ccea1be1afe55f105f4d4c9c4"
1750 1834
 "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f"
... ...
@@ -1780,6 +1864,7 @@ dependencies = [
1780 1864
 "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
1781 1865
 "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
1782 1866
 "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
1867
+"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
1783 1868
 "checksum openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)" = "a51f452b82d622fc8dd973d7266e9055ac64af25b957d9ced3989142dc61cb6b"
1784 1869
 "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
1785 1870
 "checksum openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)" = "05636e06b4f8762d4b81d24a351f3966f38bd25ccbcfd235606c91fdb82cc60f"
... ...
@@ -1796,6 +1881,7 @@ dependencies = [
1796 1881
 "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
1797 1882
 "checksum publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5afecba86dcf1e4fd610246f89899d1924fe12e1e89f555eb7c7f710f3c5ad1d"
1798 1883
 "checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15"
1884
+"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
1799 1885
 "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db"
1800 1886
 "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
1801 1887
 "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
... ...
@@ -1810,10 +1896,11 @@ dependencies = [
1810 1896
 "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
1811 1897
 "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
1812 1898
 "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252"
1899
+"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
1813 1900
 "checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58"
1814 1901
 "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
1815 1902
 "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
1816
-"checksum reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ddcfd2c13c6af0f9c45a1086be3b9c68af79e4430b42790759e2d34cce2a6c60"
1903
+"checksum reqwest 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)" = "e57803405f8ea0eb041c1567dac36127e0c8caa1251c843cb03d43fd767b3d50"
1817 1904
 "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288"
1818 1905
 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
1819 1906
 "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f"
... ...
@@ -1845,6 +1932,8 @@ dependencies = [
1845 1932
 "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
1846 1933
 "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a"
1847 1934
 "checksum tendril 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b"
1935
+"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
1936
+"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea"
1848 1937
 "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
1849 1938
 "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
1850 1939
 "checksum tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "cec6c34409089be085de9403ba2010b80e36938c9ca992c4f67f407bb13db0b1"
... ...
@@ -1882,4 +1971,5 @@ dependencies = [
1882 1971
 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
1883 1972
 "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
1884 1973
 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1974
+"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
1885 1975
 "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
... ...
@@ -7,3 +7,7 @@ edition = "2018"
7 7
 [dependencies]
8 8
 elefren = { version = "0.19", features = ["toml"] }
9 9
 html2md = "0.2.9"
10
+reqwest = "0.9.17"
11
+hyper = "*"
12
+log = "0.4.6"
13
+env_logger = "0.6.1"
... ...
@@ -6,9 +6,19 @@ use std::io::prelude::*;
6 6
 use elefren::prelude::*;
7 7
 use elefren::helpers::cli;
8 8
 use elefren::helpers::toml;
9
-use elefren::entities::status;
9
+use elefren::entities::status::Status;
10
+use elefren::entities::attachment::Attachment;
11
+
12
+use reqwest;
13
+
14
+use hyper::Uri;
15
+
16
+#[macro_use] use log;
17
+use env_logger;
10 18
 
11 19
 fn main() {
20
+    env_logger::init();
21
+
12 22
     let client = if let Ok(data) = toml::from_file("mastodon.toml") {
13 23
         Mastodon::from(data)
14 24
     } else {
... ...
@@ -21,41 +31,56 @@ fn main() {
21 31
         mastodon
22 32
     };
23 33
 
34
+    info!("Starting up...");
24 35
     client
25 36
         .favourites().unwrap()
26 37
         .items_iter()
27 38
         .take(2)
28
-        .for_each(move |record| dump_record(record))
29
-        ;
30
-
31
-    // status
32
-    // status.account.acct (username)
33
-    // status.id (id)
34
-    // status.content
35
-    // status.media_attachments
36
-    //  -> attachment.remote_url / attachment.url
37
-    //     attachment.
39
+        .for_each(move |record| dump_record(record));
38 40
 }
39 41
 
40
-fn dump_record(record: status::Status) -> () {
42
+fn dump_record(record: Status) -> () {
43
+    debug!("Retriving record {}", record.id);
41 44
     create_structure(&record);
42 45
     save_content(&record);
46
+    save_attachments(&record);
43 47
 }
44 48
 
45
-fn toot_dir(record: &status::Status) -> PathBuf {
49
+fn toot_dir(record: &Status) -> PathBuf {
46 50
     Path::new("data")
47 51
         .join(&record.account.acct)
48 52
         .join(&record.id)
49 53
 }
50 54
 
51
-fn create_structure(record: &status::Status) -> () {
55
+fn create_structure(record: &Status) -> () {
52 56
     std::fs::create_dir_all(toot_dir(record))
53 57
         .expect("Failed to create the storage path");
54 58
 }
55 59
 
56
-fn save_content(record: &status::Status) -> () {
60
+fn save_content(record: &Status) -> () {
57 61
     if let Ok(mut fp) = File::create(toot_dir(&record).join("toot.md")) {
62
+        debug!("Saving content of {}..", record.id);
58 63
         fp.write_all(html2md::parse_html(&record.content).as_bytes())
59 64
             .expect("Failed to save content");
60 65
     }
61 66
 }
67
+
68
+fn save_attachments(record: &Status) -> () {
69
+    debug!("Saving attachments of {}...", record.id);
70
+    let base_path = toot_dir(&record);
71
+    record.media_attachments
72
+        .iter()
73
+        .for_each(move |x| save_attachment(&x, &base_path));
74
+}
75
+
76
+fn save_attachment(attachment: &Attachment, base_path: &PathBuf) -> (){
77
+    debug!("Saving attachment {}", attachment.url);
78
+    let uri:Uri = attachment.url.parse().expect("Invalid URL");
79
+    let body = reqwest::get(&attachment.url).expect("Failed to connect to server")
80
+        .text().expect("Failed to retrieve attachment");
81
+
82
+    if let Ok(mut fp) = File::create(base_path.join(uri.path())) {
83
+        fp.write_all(body.as_bytes())
84
+            .expect("Failed to save the attachment");
85
+    }
86
+}