McSib / e621_downloader

E621 and E926 downloader made in the Rust programming langauge.
Apache License 2.0
60 stars 13 forks source link

thread 'main' panicked at 'Json was unable to deserialize to entry! #35

Closed lordkitsuna closed 4 years ago

lordkitsuna commented 4 years ago

Hi there, glad to see this update. I seem to be having issues with the latest version. during build i get warnings.

warning: unused import: `failure::Error`
 --> src/e621/mod.rs:9:5
  |
9 | use failure::Error;
  |     ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `PostCollection`
  --> src/e621/mod.rs:15:37
   |
15 | use crate::e621::grabber::{Grabber, PostCollection};
   |                                     ^^^^^^^^^^^^^^

warning: unused import: `crate::e621::io::Login`
  --> src/e621/mod.rs:20:5
   |
20 | use crate::e621::io::Login;
   |     ^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `failure::Error`
 --> src/e621/blacklist.rs:3:5
  |
3 | use failure::Error;
  |     ^^^^^^^^^^^^^^

warning: unused import: `reqwest::get`
 --> src/e621/blacklist.rs:7:5
  |
7 | use reqwest::get;
  |     ^^^^^^^^^^^^

warning: unused import: `serde_json::Value`
 --> src/e621/grabber.rs:4:5
  |
4 | use serde_json::Value;
  |     ^^^^^^^^^^^^^^^^^

warning: unused import: `BulkPostEntry`
  --> src/e621/grabber.rs:10:5
   |
10 |     BulkPostEntry, PoolEntry, PostEntry, RequestSender, SetEntry, UserEntry,
   |     ^^^^^^^^^^^^^

warning: unused import: `WWW_AUTHENTICATE`
  --> src/e621/sender.rs:15:44
   |
15 | use self::reqwest::header::{AUTHORIZATION, WWW_AUTHENTICATE};
   |                                            ^^^^^^^^^^^^^^^^

warning: unused import: `to_string`
  --> src/e621/sender.rs:16:36
   |
16 | use self::serde_json::{from_value, to_string, Value};
   |                                    ^^^^^^^^^

warning: unused import: `std::fs::write`
  --> src/e621/sender.rs:19:5
   |
19 | use std::fs::write;
   |     ^^^^^^^^^^^^^^

warning: use of deprecated item 'e621::grabber::Grabber::grab_blacklist': This has been deprecated as the new blacklist system is being developed.
   --> src/e621/grabber.rs:117:17
    |
117 |         grabber.grab_blacklist();
    |                 ^^^^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: use of deprecated item 'e621::sender::RequestSender::get_pool_entry': This uses the old API to grab the pool and is no longer used for the new API
   --> src/e621/grabber.rs:248:68
    |
248 |             let mut searched_pool: PoolEntry = self.request_sender.get_pool_entry(id, page);
    |                                                                    ^^^^^^^^^^^^^^

warning: unused variable: `blacklist_entries`
   --> src/e621/grabber.rs:149:17
    |
149 |             let blacklist_entries: Vec<String> =
    |                 ^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_blacklist_entries`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
   --> src/e621/grabber.rs:248:17
    |
248 |             let mut searched_pool: PoolEntry = self.request_sender.get_pool_entry(id, page);
    |                 ----^^^^^^^^^^^^^
    |                 |
    |                 help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: method is never used: `is_tag_special`
   --> src/e621/blacklist.rs:144:5
    |
144 |     fn is_tag_special(&self, tag: &String) -> bool {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: field is never read: `blacklist_entries`
   --> src/e621/blacklist.rs:450:5
    |
450 |     blacklist_entries: Vec<String>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `from_tags`
   --> src/e621/grabber.rs:115:5
    |
115 |     pub fn from_tags(groups: &[Group], request_sender: RequestSender) -> Grabber {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `grab_blacklist`
   --> src/e621/grabber.rs:135:5
    |
135 |     pub fn grab_blacklist(&mut self) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `get_posts_from_pool`
   --> src/e621/grabber.rs:243:5
    |
243 |     pub fn get_posts_from_pool(&self, id: &str) -> (String, Vec<PostEntry>) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `get_entry_from_id`
   --> src/e621/sender.rs:510:5
    |
510 | /     pub fn get_entry_from_id<T>(&self, id: &str, url_type_key: &str) -> T
511 | |     where
512 | |         T: DeserializeOwned,
513 | |     {
...   |
521 | |         .expect("Json was unable to deserialize to entry!")
522 | |     }
    | |_____^

warning: method is never used: `get_pool_entry`
   --> src/e621/sender.rs:564:5
    |
564 |     pub fn get_pool_entry(&self, id: &str, page: u16) -> PoolEntry {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `get_tag_by_id`
   --> src/e621/sender.rs:630:5
    |
630 |     pub fn get_tag_by_id(&self, id: &str) -> TagEntry {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `get_blacklist`
   --> src/e621/sender.rs:655:5
    |
655 |     pub fn get_blacklist(&self, login: &Login) -> UserEntry {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: 23 warnings emitted

But it does seem to finish, however when i then run the program

thread 'main' panicked at 'Json was unable to deserialize to entry!: reqwest::Error { kind: Decode, source: Error("expected ident", line: 1, column: 2) }', src/e621/sender.rs:543:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Running the backtrace shows

thread 'main' panicked at 'Json was unable to deserialize to entry!: reqwest::Error { kind: Decode, source: Error("expected ident", line: 1, column: 2) }', src/e621/sender.rs:543:28
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /build/rust/src/rustc-1.44.0-src/vendor/backtrace/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /build/rust/src/rustc-1.44.0-src/vendor/backtrace/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1504
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:511
  11: rust_begin_unwind
             at src/libstd/panicking.rs:419
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:111
  13: core::option::expect_none_failed
             at src/libcore/option.rs:1268
  14: core::result::Result<T,E>::expect
             at /build/rust/src/rustc-1.44.0-src/src/libcore/result.rs:963
  15: e621_downloader::e621::sender::RequestSender::get_entry_from_appended_id
             at src/e621/sender.rs:543
  16: e621_downloader::e621::WebConnector::process_blacklist
             at src/e621/mod.rs:72
  17: e621_downloader::main
             at src/main.rs:40
  18: std::rt::lang_start::{{closure}}
             at /build/rust/src/rustc-1.44.0-src/src/libstd/rt.rs:67
  19: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  20: std::panicking::try::do_call
             at src/libstd/panicking.rs:331
  21: std::panicking::try
             at src/libstd/panicking.rs:274
  22: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  23: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  24: std::rt::lang_start
             at /build/rust/src/rustc-1.44.0-src/src/libstd/rt.rs:67
  25: main
  26: __libc_start_main
  27: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
McSib commented 4 years ago

First off, I would like to say not to worry about the warnings, the deprecated items aren't actually used in the running code. All of it is dead code now. I had to do this to get this build functioning as quickly as possible.

With your error stating it couldn't Deserialize to entry! That means there is a request for something specific that was incorrect. From the way it looks, the program was unable to authorize and login to your account for e621. I would highly recommend deleting your already existing one and letting the program create the new login file. The reason I say this is because the program renamed PasswordHash to APIKey, and then added a new field for you to enter your user ID, the one for your account on e621. If you need help finding it, it's the numbers at the end of the URL for your main profile (e.g https://e621.net/users/269797, my ID is 269797). This should fix your issue, but I'll take a deeper look into it, give me an update if this doesn't work.

If I remember too, I didn't add any safeguard against this new blacklist, pretty much enforcing the use of the blacklist, I'll fix this in the next build.

lordkitsuna commented 4 years ago

oh, i had not used the login before is that required now? not a big deal i just didn't think to set that up i had never used it before lol Thanks for pointing it out. This was a clean download from the git after deleting the old so nothing old was around. after deleting the blank file so it could remake then adding my login details i get the new error of "thread 'main' panicked at 'User isn't logged in!', src/e621/mod.rs:77:30" i have verified the details are correct in the file. do i need to perhaps remove the " " ? i left them in place as thats not uncommon with login details in a conf

McSib commented 4 years ago

Okay, so I pushed a new commit that should fix this issue. It's nothing too much added, just an if statement that actually checks and verifies the user has login credentials for the blacklist. If the login is empty, it won't enforce it. There is something else to note, if the user isn't logged in, the e621 server now has a global filter that will blacklist posts. This filter has a blacklist of sorts with this entry only: young -rating:s. If there are any posts that match this filter, it will nullify the URL for the image and make it impossible to grab or download. So if you go for content along those lines, then logging in is required. Beyond that, you can still use my program logged out without any problem. Hopefully, this fixes your issue.

lordkitsuna commented 4 years ago

logging in would be nice for having my own blacklist lol. i am still getting 'User isn't logged in!', src/e621/mod.rs:77:30 when i use my credentials. I have double checked they are all correct i even use this api key for a mobile app so i know that much is correct. It does however now work fine when the login file is left blank

McSib commented 4 years ago

Send me your login.json file with the APIKey left blank. I'll take a look and see what's wrong.

lordkitsuna commented 4 years ago

Sure here it is as a file just to ensure all formatting preserved login.zip

{
  "Username": "LordKitsuna",
  "APIKey": "",
  "UserID": "132970",
  "DownloadFavorites": false
}

and here is just a paste

McSib commented 4 years ago

I would say for you to give me your APIKey, so I can send a manual request and see what's going on. But I can't do that privately on Github. The current issue seems to be that the program can't get your blacklist string. When it tries to use the blacklist, it will send a request for your account with your username and API key. This should show me your blacklist, but that doesn't seem to be the case. I'll look into it and see what I can find. This is still an indev build after all, there are bound to be a few of these sneaky bugs.

lordkitsuna commented 4 years ago

Feel free to add me on discord, same name i can use that to send api key and just delete it when you are done testing

lordkitsuna commented 4 years ago

Actually i just solved this one, i realized my blacklist was all on my app and didnt actually reflect on my e621 account. On my account it was blank. after copying my blacklist to the site itself the program works fine. So it seems its issue is with blank blacklists

McSib commented 4 years ago

Updated the code so now the program will ignore empty blacklists. This should fix the issue.