bryanmr / Steamy_Cats

A Steam Game Category Sorter Written in Bash
GNU General Public License v3.0
17 stars 1 forks source link

Negative number of apps when in offline/private mode #13

Closed RiderExMachina closed 5 years ago

RiderExMachina commented 5 years ago

The script fails and gives a negative number when in offline mode. Easiest way to recreate is to comment out line 28. I'm getting -1 after successfully running the script, but before got -35. When I was researching I thought lines 19-24 were suspicious.

Error:

Our config file is: /home/rider/.steam/steam/userdata/98177731/7/remote/sharedconfig.vdf
Downloading your community profile, if public, and then getting full list of games you own
Is your community profile private?
We can only process games in local configs, which is not complete.
As a workaround, you can add all games to a group and restart Steam, then we can process them.
Begin processing -1 lines of configuration in /home/rider/.steam/steam/userdata/98177731/7/remote/sharedconfig.vdf
Gathering the list of files to download from Steam now!
Downloading files for these game IDs:
RiderExMachina commented 5 years ago

I've done a little bit of research on this and it looks like if I manually enter echo $(grep -n \"Apps\" $HOME/.steam/steam/userdata/*/7/remote/sharedconfig.vdf | cut -d: -f1) I get 38 19641 -- as in there are two options there. Adding | head -n 1 and then keeping the original +2 at the end of the line gives me 38+2. I don't think this is the intended result...

Full output:

$ echo $(grep -n \"Apps\" $HOME/.steam/steam/userdata/*/7/remote/sharedconfig.vdf | cut -d: -f1 | head -n 1)
38

$ echo $(grep -n \"Apps\" $HOME/.steam/steam/userdata/*/7/remote/sharedconfig.vdf | cut -d: -f1 | head -n 1)+2
38+2
RiderExMachina commented 5 years ago

Changing the code to

        let BEGIN_APPS=$(($(grep -n \"Apps\" "$1" | cut -d: -f1 | head -n 1)+2))
        echo "BEGIN_APPS is $BEGIN_APPS"
        # We skip the bracket and anything before the Apps section
        let END_APPS=$(($(grep -n $'^\t\t\t\t}' "$1" | cut -d: -f1 | head -n 1)-1))
        if [ $END_APPS -lt $BEGIN_APPS ]
        then
                let END_APPS=$(($(grep -n $'^\t\t\t\t}' "$1" | cut -d: -f1 | sed -n 2p)-1))
        fi
        echo "END_APPS is $END_APPS"
        # Fixing the count here
        let COUNT_LINES=$END_APPS-$BEGIN_APPS+1
        echo "COUNT_LINES is $COUNT_LINES"

Changes the output to:

Our config file is: /home/rider/.steam/steam/userdata/98177731/7/remote/sharedconfig.vdf
BEGIN_APPS is 40
END_APPS is 36
COUNT_LINES is -3
bryanmr commented 5 years ago

https://github.com/bryanmr/Steamy_Cats/commit/8aeb65bddeac58201045e6d6bd08ab5a67fe3403

Not sure that will help. I changed the logic to try more than once, but trying twice should have gotten it. We are looking for END_APPS to be 19641+1.

bryanmr commented 5 years ago

The let performs math on the string after it, setting the value to the variable name provided.

https://ss64.com/bash/let.html

RiderExMachina commented 5 years ago

New Output:

We can only process games in local configs, which is not complete.
As a workaround, you can add all games to a group and restart Steam, then we can process them.
BEGIN_APPS is 40
END_APPS is 19616
COUNT_LINES is 19577
Begin processing 19577 lines of configuration in /home/rider/.steam/steam/userdata/98177731/7/remote/sharedconfig.vdf
Gathering the list of files to download from Steam now!
Downloading files for these game IDs:  { {\
2 downloads started of 2 total
Downloads complete for the Store Frontend.
Most recent ProtonDB file appears to be: ./reports_jan1_2019.tar.gz
Adding new category tags to the games!
grep: /home/rider/.local/share/steam_store_frontend/{.html: No such file or directory
grep: /home/rider/.local/share/steam_store_frontend/{\.html: No such file or directory
grep: /home/rider/.local/share/steam_store_frontend/{\.htmlgrep: /home/rider/.local/share/steam_store_frontend/{.html: No such file or directory
: No such file or directory
grep: grep: /home/rider/.local/share/steam_store_frontend/{\.html: No such file or directory
/home/rider/.local/share/steam_store_frontend/{.html: No such file or directory
grep: /home/rider/.local/share/steam_store_frontend/{.html: No such file or directory
grep: /home/rider/.local/share/steam_store_frontend/{\.html: No such file or directory
Creating final configuration

Progress!

bryanmr commented 5 years ago

It looks like something is still off by one or so, unfortunately I am not reproducing this. I might have you upload (or send privately) the config and write something to make it so I skip the selection and provide a config file to parse.

VDF being its own data format is pretty obnoxious. I tried a few parsers that other people had written but they choked on my config, so I wrote the halfway working one here. :)

Does it output a config in the end? I'd assume the config won't work even if it does, but I am curious if it is creating anything. You can check /var/tmp/newconfig.vdf or run with --debug and see /var/tmp/Steamy_Cats/fragments/* for what it is writing.

RiderExMachina commented 5 years ago

It looks like it's writing a correct config file. I have the one that was created after I added the -L flag to curl, so I'm worried that it'll screw something up...

bryanmr commented 5 years ago

I am curious if you still get errors with some of these switches: --ignore-old-categories : Gets rid of all category configuration while retaining favorites --clear-whole-config : Preserves nothing from old configuration --clean-dls : Gets rid of failed downloads and tries again

I also added these, so if you would like I could try it with your actual config. --vdf-file : Name of a VDF configuration to use instead of the script discovered one Usage: --vdf-file=/path/to/file.vdf --steam-user-id : The numeric USER ID for your Steam account Usage: --steam-user-id=77777777777777777

RiderExMachina commented 5 years ago

I tried using the --clean-dls and didn't have any different results. I haven't really had time yet to try any of the other additions yet though.

Another odd thing, I'm not getting online with my openSUSE computer. Not sure why, but I'll be online and it just says "nope, not gonna do it." I'll look at it more when I can, but I don't know when that will be.

RiderExMachina commented 5 years ago

@bryanmr So I found out that no matter if the script can find the user online it still attempts the offline download. I'll create a new issue.

bryanmr commented 5 years ago

Closing this since I believe it is fixed.