Compare commits

...

3 Commits

5 changed files with 89 additions and 84 deletions

102
Cargo.lock generated
View File

@ -70,15 +70,15 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.1.2" version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fb8038c1ddc0a5f73787b130f4cc75151e96ed33e417fde765eb5a81e3532f4" checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.3.2" version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]] [[package]]
name = "bytes" name = "bytes"
@ -168,7 +168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" checksum = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca"
dependencies = [ dependencies = [
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils 0.7.0", "crossbeam-utils",
] ]
[[package]] [[package]]
@ -179,7 +179,7 @@ checksum = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac"
dependencies = [ dependencies = [
"autocfg 0.1.7", "autocfg 0.1.7",
"cfg-if", "cfg-if",
"crossbeam-utils 0.7.0", "crossbeam-utils",
"lazy_static 1.4.0", "lazy_static 1.4.0",
"memoffset", "memoffset",
"scopeguard", "scopeguard",
@ -187,21 +187,12 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-queue" name = "crossbeam-queue"
version = "0.1.2" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
dependencies = [
"crossbeam-utils 0.6.6",
]
[[package]]
name = "crossbeam-utils"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"lazy_static 1.4.0", "crossbeam-utils",
] ]
[[package]] [[package]]
@ -354,6 +345,7 @@ dependencies = [
[[package]] [[package]]
name = "google-photoslibrary1" name = "google-photoslibrary1"
version = "0.1.0-20200203" version = "0.1.0-20200203"
source = "git+https://git.z.xinu.tv/wathiede/google-api-photoslibrary#7480a9c0a0e432169d6c300adb50276f21a54eb7"
dependencies = [ dependencies = [
"chrono", "chrono",
"google_api_auth", "google_api_auth",
@ -369,7 +361,7 @@ dependencies = [
[[package]] [[package]]
name = "google_api_auth" name = "google_api_auth"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/google-apis-rs/generator#7504e310e8c4c361aca998ea14c309d5c46967cc" source = "git+https://github.com/google-apis-rs/generator#a848301466556f16d48df64ef16b92a8327a8406"
dependencies = [ dependencies = [
"tokio 0.1.22", "tokio 0.1.22",
"yup-oauth2", "yup-oauth2",
@ -378,7 +370,7 @@ dependencies = [
[[package]] [[package]]
name = "google_field_selector" name = "google_field_selector"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/google-apis-rs/generator#7504e310e8c4c361aca998ea14c309d5c46967cc" source = "git+https://github.com/google-apis-rs/generator#a848301466556f16d48df64ef16b92a8327a8406"
dependencies = [ dependencies = [
"google_field_selector_derive", "google_field_selector_derive",
] ]
@ -386,7 +378,7 @@ dependencies = [
[[package]] [[package]]
name = "google_field_selector_derive" name = "google_field_selector_derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/google-apis-rs/generator#7504e310e8c4c361aca998ea14c309d5c46967cc" source = "git+https://github.com/google-apis-rs/generator#a848301466556f16d48df64ef16b92a8327a8406"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -611,9 +603,9 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.3.1" version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292"
dependencies = [ dependencies = [
"autocfg 1.0.0", "autocfg 1.0.0",
] ]
@ -1185,9 +1177,9 @@ dependencies = [
[[package]] [[package]]
name = "ring" name = "ring"
version = "0.16.10" version = "0.16.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "113f53b644c5442e20ff3a299be3d6c61ba143737af5bd2ab298e248a7575b2d" checksum = "741ba1704ae21999c00942f9f5944f801e977f54302af346b596287599ad1862"
dependencies = [ dependencies = [
"cc", "cc",
"lazy_static 1.4.0", "lazy_static 1.4.0",
@ -1344,9 +1336,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.46" version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b01d7f0288608a01dca632cf1df859df6fd6ffa885300fc275ce2ba6221953" checksum = "15913895b61e0be854afd32fd4163fcd2a3df34142cf2cb961b310ce694cbf90"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -1600,9 +1592,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-codec" name = "tokio-codec"
version = "0.1.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b"
dependencies = [ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"futures", "futures",
@ -1611,9 +1603,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-current-thread" name = "tokio-current-thread"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e"
dependencies = [ dependencies = [
"futures", "futures",
"tokio-executor", "tokio-executor",
@ -1621,19 +1613,19 @@ dependencies = [
[[package]] [[package]]
name = "tokio-executor" name = "tokio-executor"
version = "0.1.9" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca6df436c42b0c3330a82d855d2ef017cd793090ad550a6bc2184f4b933532ab" checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671"
dependencies = [ dependencies = [
"crossbeam-utils 0.6.6", "crossbeam-utils",
"futures", "futures",
] ]
[[package]] [[package]]
name = "tokio-fs" name = "tokio-fs"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4"
dependencies = [ dependencies = [
"futures", "futures",
"tokio-io", "tokio-io",
@ -1642,9 +1634,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-io" name = "tokio-io"
version = "0.1.12" version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674"
dependencies = [ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"futures", "futures",
@ -1653,11 +1645,11 @@ dependencies = [
[[package]] [[package]]
name = "tokio-reactor" name = "tokio-reactor"
version = "0.1.11" version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6732fe6b53c8d11178dcb77ac6d9682af27fc6d4cb87789449152e5377377146" checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351"
dependencies = [ dependencies = [
"crossbeam-utils 0.6.6", "crossbeam-utils",
"futures", "futures",
"lazy_static 1.4.0", "lazy_static 1.4.0",
"log 0.4.8", "log 0.4.8",
@ -1698,9 +1690,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-sync" name = "tokio-sync"
version = "0.1.7" version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d06554cce1ae4a50f42fba8023918afa931413aded705b560e29600ccf7c6d76" checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee"
dependencies = [ dependencies = [
"fnv", "fnv",
"futures", "futures",
@ -1708,9 +1700,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-tcp" name = "tokio-tcp"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72"
dependencies = [ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"futures", "futures",
@ -1722,13 +1714,13 @@ dependencies = [
[[package]] [[package]]
name = "tokio-threadpool" name = "tokio-threadpool"
version = "0.1.17" version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c32ffea4827978e9aa392d2f743d973c1dfa3730a2ed3f22ce1e6984da848c" checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89"
dependencies = [ dependencies = [
"crossbeam-deque", "crossbeam-deque",
"crossbeam-queue", "crossbeam-queue",
"crossbeam-utils 0.6.6", "crossbeam-utils",
"futures", "futures",
"lazy_static 1.4.0", "lazy_static 1.4.0",
"log 0.4.8", "log 0.4.8",
@ -1739,11 +1731,11 @@ dependencies = [
[[package]] [[package]]
name = "tokio-timer" name = "tokio-timer"
version = "0.2.12" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1739638e364e558128461fc1ad84d997702c8e31c2e6b18fb99842268199e827" checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296"
dependencies = [ dependencies = [
"crossbeam-utils 0.6.6", "crossbeam-utils",
"futures", "futures",
"slab", "slab",
"tokio-executor", "tokio-executor",
@ -1751,9 +1743,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-udp" name = "tokio-udp"
version = "0.1.5" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82"
dependencies = [ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"futures", "futures",
@ -1766,9 +1758,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-uds" name = "tokio-uds"
version = "0.2.5" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798"
dependencies = [ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"futures", "futures",

View File

@ -10,7 +10,7 @@ edition = "2018"
yup-oauth2 = "^3.1" yup-oauth2 = "^3.1"
google_api_auth = { git = "https://github.com/google-apis-rs/generator", features = ["with-yup-oauth2"] } google_api_auth = { git = "https://github.com/google-apis-rs/generator", features = ["with-yup-oauth2"] }
# TODO, use https://git.z.xinu.tv/wathiede/google-api-photoslibrary and figure out auth story. # TODO, use https://git.z.xinu.tv/wathiede/google-api-photoslibrary and figure out auth story.
google-photoslibrary1 = { path = "../google-api-photoslibrary" } google-photoslibrary1 = { git = "https://git.z.xinu.tv/wathiede/google-api-photoslibrary" }
structopt = "0.3.9" structopt = "0.3.9"
regex = "1.3.4" regex = "1.3.4"
log = "0.4.8" log = "0.4.8"

View File

@ -36,3 +36,7 @@
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
.figure {
width: 285px;
}

View File

@ -1,5 +1,7 @@
import React from 'react'; import React from 'react';
import './App.css';
class Album extends React.Component { class Album extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -25,18 +27,16 @@ class Album extends React.Component {
} else if (album !== null) { } else if (album !== null) {
console.log(album); console.log(album);
return album.map((a) => { return album.map((a) => {
let img = <img src="https://via.placeholder.com/256x128" className="mr-3" alt="unset"/>; // TODO(wathiede): use coverPhotoMediaItemId and fetch from a
if (a.coverPhotoBaseUrl !== undefined) { // locally cached image.
img = <img src={ a.coverPhotoBaseUrl + "=w256" } className="mr-3" alt={ a.title }/>; return <figure key={ a.id } className="figure">
} <img src={ a.baseUrl + "=w256-h256-c" } className="mr-3" alt={ a.filename }/>
<figcaption className="figure-caption">
let figure = <figure key={ a.id } className="figure"> <a key={ a.id } href={ a.productUrl }>
{img} <p className="text-truncate">{ a.filename}</p>
<figcaption className="figure-caption">{ a.title || "No title" } - { a.mediaItemsCount || 0 } photos </figcaption>
</figure>;
return <a key={ a.id } href={ a.productUrl }>
{ figure }
</a> </a>
</figcaption>
</figure>
}); });
} else { } else {
return <h2>Loading...</h2>; return <h2>Loading...</h2>;

View File

@ -123,8 +123,21 @@ impl<'a> Iterator for SearchIter<'a> {
} }
} }
fn search_media_items(client: &photos::Client, album_id: String) -> Result<(), Box<dyn Error>> { fn print_media_items(media_items: Vec<MediaItem>) {
let mut total = 0; for mi in &media_items {
println!(
"{} {}",
mi.id.as_ref().unwrap_or(&"NO ID".to_string()),
mi.filename.as_ref().unwrap_or(&"NO FILENAME".to_string())
);
}
println!("({}) items total", media_items.len());
}
fn search_media_items(
client: &photos::Client,
album_id: String,
) -> Result<Vec<MediaItem>, Box<dyn Error>> {
let media_items = SearchIter::new( let media_items = SearchIter::new(
&client, &client,
SearchMediaItemsRequest { SearchMediaItemsRequest {
@ -133,18 +146,10 @@ fn search_media_items(client: &photos::Client, album_id: String) -> Result<(), B
page_size: Some(100), page_size: Some(100),
..Default::default() ..Default::default()
}, },
); )
for mi in media_items { .filter_map(|mi| mi.ok())
let mi = mi?; .collect();
total += 1; Ok(media_items)
println!(
"{} {}",
mi.id.unwrap_or("NO ID".to_string()),
mi.filename.unwrap_or("NO FILENAME".to_string())
);
}
println!("({}) items total", total);
Ok(())
} }
fn sync_albums( fn sync_albums(
@ -159,11 +164,12 @@ fn sync_albums(
info!("making album directory {}", album_dir.to_string_lossy()); info!("making album directory {}", album_dir.to_string_lossy());
fs::create_dir_all(&album_dir)?; fs::create_dir_all(&album_dir)?;
} }
let j = serde_json::to_string(&albums)?;
let album = search_media_items(client, a.id.as_ref().expect("unset album id").to_string())?;
let j = serde_json::to_string(&album)?;
let path = album_dir.join("album.json"); let path = album_dir.join("album.json");
info!("saving {}", path.to_string_lossy()); info!("saving {}", path.to_string_lossy());
fs::write(path, j)?; fs::write(path, j)?;
search_media_items(client, a.id.as_ref().expect("unset album id").to_string());
} }
// Serialize it to a JSON string. // Serialize it to a JSON string.
let j = serde_json::to_string(&albums)?; let j = serde_json::to_string(&albums)?;
@ -223,7 +229,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
print_albums(list_albums(&client, title_filter)?); print_albums(list_albums(&client, title_filter)?);
Ok(()) Ok(())
} }
Command::SearchMediaItems { album_id } => search_media_items(&client, album_id), Command::SearchMediaItems { album_id } => {
print_media_items(search_media_items(&client, album_id)?);
Ok(())
}
Command::Sync { Command::Sync {
title_filter, title_filter,
output, output,