Code Monkey home page Code Monkey logo

tts-backup's Introduction

TTS-Backup

TTS-Backup backs up Tabletop simulator save games and mods to a Zip file, bundling locally cached images and models within a single archive.

This only handles saves and mods in JSON format.

Requirements & Installation

A Python 3.3 (or newer) interpreter is required. For Windows users, the ActivePython distribution is recommended.

Alternatively, a binary release for the Windows platform is available here.

Optionally, to use the source distribution, download the current release, and either use pip or easy_install on the archive file, or extract the contents and run python setup.py install.

Usage

All content referenced within the mod or save must have been locally cached from within TTS before a backup can be made. Note that when game items are contained within bags, TTS will only locally cache the respective assets once they are removed from the bag.

By default, TTS-Backup will assume that cached data is located in ~/Documents/My Games/Tabletop Simulator.

TTS-Backup is a console application. For stern opponents of the CLI, a minimal GUI is provided.

Usage flags and arguments are as follows:

usage: tts-backup [-h] [--gamedata PATH] [--outname FILENAME] [--dry-run]
                  [--ignore-missing] [--comment COMMENT]
                  FILENAME

Back-up locally cached content from a TTS .json file.

positional arguments:
  FILENAME              The save file or mod in JSON format.

optional arguments:
  -h, --help            show this help message and exit
  --gamedata PATH       The path to the TTS game data directory.
  --outname FILENAME, -o FILENAME
                        The name for the output archive.
  --dry-run, -n         Only print which files would be backed up.
  --ignore-missing, -i  Don’t abort the backup when files are missing.
  --comment COMMENT, -c COMMENT
                        A comment to be stored in the resulting Zip.

TTS-Prefetch

TTS-Prefetch downloads assets specified within a TTS JSON save file and stores them within the TTS cache. This is handy if you want to ensure that all mod assets are present, e. g., when several mods have been updated, or when a mod uses bags, which normally require that all pieces are unpacked manually before they are fetched and stored inside the TTS cache.

Requirements & Installation

Cf. above.

Usage

By default, TTS-Prefetch will assume that cached data is located in ~/Documents/My Games/Tabletop Simulator.

TTS-Prefetch is a console application. For stern opponents of the CLI, a minimal GUI is provided.

Usage flags and arguments are as follows:

usage: tts-prefetch [-h] [--gamedata PATH] [--dry-run] [--refetch] [--relax]
                    [--timeout TIMEOUT] [--user-agent USER_AGENT]
                    FILENAME [FILENAME ...]

Download assets referenced in TTS .json files.

positional arguments:
  FILENAME              The save file or mod in JSON format.

optional arguments:
  -h, --help            show this help message and exit
  --gamedata PATH       The path to the TTS game data directory.
  --dry-run, -n         Only print which files would be downloaded.
  --refetch, -r         Rewrite objects that already exist in the cache.
  --relax, -x           Do not abort when encountering an unexpected MIME
                        type.
  --timeout TIMEOUT, -t TIMEOUT
                        Connection timeout in s.
  --user-agent USER_AGENT, -a USER_AGENT
                        HTTP user-agent string.

tts-backup's People

Contributors

alxbridge avatar eigengrau avatar hopi avatar kylejameswalker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tts-backup's Issues

Python compatibility / errors / unclean code

You really should add the encoding hint on the start of the code

# -*- coding: utf-8 -*-

While python3 did not croak initially its a thing that will happen sooner or later if utf8 literals appear outside strings. Python2 denies it out of the box.

Installing using Py2 did produce sort' of worked but the code did not. Py3 neighter but with different errors.

Py2:
http://pastebin.com/Vucxucnf

Py3:
http://pastebin.com/2jwTxHu2

Py2 usage (ignoring the install errors):
it basically croaks about missing encoding in util.py (not further checked)

Py3 usage (ignoring the install errors):
$ tts-backup Traceback (most recent call last): File "/usr/local/bin/tts-backup", line 9, in <module> load_entry_point('tts-backup==0.1.0.0.dev84-3283dfc', 'console_scripts', 'tts-backup')() File "/usr/lib/python3/dist-packages/pkg_resources.py", line 305, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2244, in load_entry_point return ep.load() File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1954, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "/usr/local/lib/python3.1/dist-packages/tts_backup-0.1.0.0.dev84_3283dfc-py3.1.egg/tts_tools/backup/__init__.py", line 9, in <module> from tts_tools.libtts import ( File "/usr/local/lib/python3.1/dist-packages/tts_backup-0.1.0.0.dev84_3283dfc-py3.1.egg/tts_tools/libtts.py", line 25 yield from seekURL(v, newtrail) ^ SyntaxError: invalid syntax

$ python --version
Python 2.6.6
$ python3 --version
Python 3.1.3

No restore function

There's no option to restore a mod after it's been backed up. I think it would need to extract the zip, place the JSON in the right location, and then edit WorkshopFileInfos.json.

Prefetch seems to be downloading all assets, despite of refetch flag not being set

I used tts-prefetch with the following params:

tts-prefetch --gamedata X:\XXX\SteamLibrary\steamapps\common\Tabletop Simulator\Tabletop Simulator_Data --user-agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0 X:\XXX\SteamLibrary\steamapps\common\Tabletop Simulator\Tabletop Simulator_Data\Mods\Workshop\1516223037.json

and it appears like it's downloading all assets again, despite the fact that the --refetch flag isn't set and I know for a fact, that most assets are already in \Mods\Images in the gamedata path specified in the command.

Am I doing something wrong or might this be a bug with custom gamedata paths?

Getting IncompleteRead on file that's fine

Hey there! When pre-fetching, I'm getting an error on a particular url which just doesn't allow the tool to go on. I've checked the url and had no issue downloading the file by hand (just by inputting the url).

This is what I'm getting:

(base) fede@alexandria:~/tts-backup$ tts-prefetch --relax --gamedata ~/.local/share/Tabletop\ Simulator/ ~/.local/share/Tabletop\ Simulator/Mods/Workshop/912353521.json 
Prefetching assets for /home/fede/.local/share/Tabletop Simulator/Mods/Workshop/912353521.json (Clank! [Scripted]).
https://www.dropbox.com/s/9hikwytlw7hk5vk/Mummy.jpg?dl=1 (1217.905 kb): Traceback (most recent call last):
  File "/home/fede/anaconda3/bin/tts-prefetch", line 33, in <module>
    sys.exit(load_entry_point('tts-backup==0.1.0.3.dev114+7969805', 'console_scripts', 'tts-prefetch')())
  File "/home/fede/anaconda3/lib/python3.7/site-packages/tts_backup-0.1.0.3.dev114+7969805-py3.7.egg/tts_tools/prefetch/cli.py", line 76, in console_entry
  File "/home/fede/anaconda3/lib/python3.7/site-packages/tts_backup-0.1.0.3.dev114+7969805-py3.7.egg/tts_tools/prefetch/__init__.py", line 216, in prefetch_files
  File "/home/fede/anaconda3/lib/python3.7/site-packages/tts_backup-0.1.0.3.dev114+7969805-py3.7.egg/tts_tools/prefetch/__init__.py", line 174, in prefetch_file
  File "/home/fede/anaconda3/lib/python3.7/http/client.py", line 470, in read
    s = self._safe_read(self.length)
  File "/home/fede/anaconda3/lib/python3.7/http/client.py", line 622, in _safe_read
    raise IncompleteRead(b''.join(s), amt)
http.client.IncompleteRead: IncompleteRead(1203604 bytes read, 14301 more expected)

Can't fetch file from google drive

When i try to fetch https://drive.google.com/uc?export=download&id=0B42Yr9OZx2KEQklXS1QwNnNJM0E with --relax flag and firefox 75 user-agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0 i get this html file instead of .obj file

Without user-agent result is defferent and more readable

<!DOCTYPE html><html><head><title>Google Drive - Quota exceeded</title><meta http-equiv="content-type" content="text/html; charset=utf-8"/><link href=&#47;static&#47;doclist&#47;client&#47;css&#47;3114378575&#45;untrustedcontent.css rel="stylesheet"><link rel="icon" href="https://ssl.gstatic.com/docs/doclist/images/infinite_arrow_favicon_4.ico"/><style nonce="k/MXhZ6+ZYyKEbQymbRIVg">#gbar,#guser{font-size:13px;padding-top:0px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
</style><script nonce="k/MXhZ6+ZYyKEbQymbRIVg"></script></head><body><div id=gbar><nobr><a target=_blank class=gb1 href="https://www.google.com/webhp?tab=ow">Search</a> <a target=_blank class=gb1 href="http://www.google.com/imghp?hl=en&tab=oi">Images</a> <a target=_blank class=gb1 href="https://maps.google.com/maps?hl=en&tab=ol">Maps</a> <a target=_blank class=gb1 href="https://play.google.com/?hl=en&tab=o8">Play</a> <a target=_blank class=gb1 href="https://www.youtube.com/?gl=US&tab=o1">YouTube</a> <a target=_blank class=gb1 href="https://news.google.com/nwshp?hl=en&tab=on">News</a> <a target=_blank class=gb1 href="https://mail.google.com/mail/?tab=om">Gmail</a> <b class=gb1>Drive</b> <a target=_blank class=gb1 style="text-decoration:none" href="https://www.google.com/intl/en/about/products?tab=oh"><u>More</u> &raquo;</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a target="_self" href="/settings?hl=en_US" class=gb4>Settings</a> | <a target=_blank  href="//support.google.com/drive/?p=web_home&hl=en_US" class=gb4>Help</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://drive.google.com/uc%3Fexport%3Ddownload%26id%3D0B42Yr9OZx2KEQklXS1QwNnNJM0E&service=writely" class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div class="uc-main"><div id="uc-text"><p class="uc-error-caption">Sorry, you can&#39;t view or download this file at this time.</p><p class="uc-error-subcaption">Too many users have viewed or downloaded this file recently. Please try accessing the file again later. If the file you are trying to access is particularly large or is shared with many people, it may take up to 24 hours to be able to view or download the file. If you still can't access a file after 24 hours, contact your domain administrator.</p></div></div><div class="uc-footer"><hr class="uc-footer-divider">&copy; 2020 Google - <a class="goog-link" href="//support.google.com/drive/?p=web_home">Help</a> - <a class="goog-link" href="//support.google.com/drive/bin/answer.py?hl=en_US&amp;answer=2450387">Privacy & Terms</a></div></body></html>

Too many users have viewed or downloaded this file recently. Please try accessing the file again later.

Unable to get Windows binary CLI to function

I must be doing something wrong, but running something like:

tts-prefetch.exe -n FILENAME 17852265.json

Doesn't do anything.

I've tried several variations, including specifying the gamedata path, etc. I don't get any errors, it just seems to do nothing. The only way I can get an error is by attempting to run tts-prefetch.exe without any arguments.

What am I doing wrong? The GUI works fine.

Backup all mods at once

I've extracted the task mentioned in #11 to enable downloading/backing up all mods at once.

Here's my current workaround (using Git Bash/MINGW64 on Windows). The script goes through all Workshop JSON files and calls tts-prefetch followed by tts-backup:

#!/usr/bin/env bash

MODS="$HOME/Documents/My Games/Tabletop Simulator/Mods/Workshop"

find "$MODS" -name "*.json" | while read file; do
  tts-prefetch "$file"
  tts-backup "$file"
done

Error 403 (Forbidden) on paste.ee

I got Error 403 (Forbidden) erros while prefatching files from paste.ee. It seems that this always happens on paste.ee but if I open the page with the browser, I got no error. You will get this error with Mage Knigth. Please fix this, because your tool is awesome. Thanks.

Various features that'd be great to have

  • list all missing files
  • remove all files that aren't part of an installed mod (i.e. clean up)
  • download/backup all mods
  • restore mod (as mentioned in #6, mentioning it here again since that issue is over 2 years old)

I have only glanced at the code and I don't know how much time I'd be able to dedicate to this project, but generally speaking: I'd be happy to help with this.

Language-specific URLs

Hi, thank you for creating TTS-Backup! Since v13.0 of Tabletop Simulator it is possible to assign language-specific URLs to the assets. Example: {en}url1{fr}url2, and so on. Currently, TTS-Backup seems to be unable to resolve these language specific URLs (i.e. to identify url1 and url2 as two separate URLs/files to be downloaded). Instead, it seems to only download the last URL (so url2 in the example).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.