├── .gitattributes ├── .gitmodules ├── setup.py ├── README.md ├── LICENSE ├── .github └── workflows │ ├── sync-submodules.yml │ ├── upload-to-pip.yml │ └── sync_and_publish.yml └── .gitignore /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "stashapi"] 2 | path = stashapi 3 | url = https://github.com/stg-annon/stashapi.git 4 | branch = tools-sm 5 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from setuptools import setup 3 | 4 | # The directory containing this file 5 | HERE = pathlib.Path(__file__).parent 6 | 7 | # The text of the README file 8 | README = (HERE / "README.md").read_text() 9 | 10 | setup( 11 | name="stashapp-tools", 12 | version="main", 13 | description="A python library for interfacing with a stashapp's API", 14 | long_description=README, 15 | long_description_content_type="text/markdown", 16 | url="https://github.com/stg-annon/stashapp-tools", 17 | author="stg-annon", 18 | author_email="14135675+stg-annon@users.noreply.github.com", 19 | license="MIT", 20 | classifiers=[ 21 | "License :: OSI Approved :: MIT License", 22 | "Programming Language :: Python :: 3", 23 | "Programming Language :: Python :: 3.10", 24 | ], 25 | packages=["stashapi"], 26 | include_package_data=True, 27 | install_requires=["requests"], 28 | ) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # stashapp-tools 2 | This library primarily serves as a API wrapper for [Stash](https://github.com/stashapp/stash) written in python 3 | 4 | ## Requirements 5 | Developed using python 3.11.X with attempts to make things as backwards compatible where possible, if you are having issues please try using python 3.11 6 | 7 | ## Installation 8 | 9 | ##### To install from PyPI use this command: 10 | `pip install stashapp-tools` 11 | 12 | ##### To install directly from this repo use this command: 13 | `pip install git+https://github.com/stg-annon/stashapp-tools` 14 | 15 | ## Usage 16 | ```python 17 | import stashapi.log as log 18 | from stashapi.stashapp import StashInterface 19 | 20 | stash = StashInterface({ 21 | "scheme": "http", 22 | "host":"localhost", 23 | "port": "9999", 24 | "logger": log 25 | }) 26 | 27 | scene_data = stash.find_scene(1234) 28 | log.info(scene_data) 29 | ``` 30 | This example creates a connection to Stash query's a scene with ID 1234 and prints the result to Stash's logs 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 stg-annon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/sync-submodules.yml: -------------------------------------------------------------------------------- 1 | name: 'Submodules Sync' 2 | 3 | on: 4 | # Allows you to run this workflow manually from the Actions tab or through HTTP API 5 | workflow_dispatch: 6 | 7 | jobs: 8 | sync: 9 | name: 'Submodules Sync' 10 | runs-on: ubuntu-latest 11 | 12 | # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest 13 | defaults: 14 | run: 15 | shell: bash 16 | 17 | steps: 18 | # Checkout the repository to the GitHub Actions runner 19 | - name: Checkout 20 | uses: actions/checkout@v2 21 | with: 22 | submodules: true 23 | 24 | # Update references 25 | - name: Git Sumbodule Update 26 | run: | 27 | git pull --recurse-submodules 28 | git submodule update --remote --recursive 29 | 30 | - name: Commit update 31 | run: | 32 | git config --global user.name 'Git bot' 33 | git config --global user.email 'bot@noreply.github.com' 34 | git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} 35 | git commit -am "Auto updated submodule references" && git push || echo "No changes to commit" 36 | -------------------------------------------------------------------------------- /.github/workflows/upload-to-pip.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Upload to PIP 3 | 4 | on: 5 | # Triggers the workflow when a release is created 6 | release: 7 | types: [created] 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | upload: 13 | runs-on: ubuntu-latest 14 | steps: 15 | # Checks-out repository under $GITHUB_WORKSPACE 16 | - name: "Checkout repository and submodules" 17 | uses: actions/checkout@v2 18 | with: 19 | submodules: recursive 20 | 21 | # Set up python 22 | - uses: actions/setup-python@v2 23 | with: 24 | python-version: 3.8 25 | 26 | # Set package version number 27 | - name: Set version number to release number 28 | run: | 29 | VERSION=${{github.event.release.tag_name}} 30 | PLACEHOLDER='version="main"' 31 | VERSION_FILE='setup.py' 32 | # ensure the placeholder is there. If grep doesn't find the placeholder 33 | # it exits with exit code 1 and github actions aborts the build. 34 | grep "$PLACEHOLDER" "$VERSION_FILE" 35 | sed -i "s/$PLACEHOLDER/version = \"${VERSION}\"/g" "$VERSION_FILE" 36 | shell: bash 37 | 38 | # Install dependencies 39 | - name: "Install dependencies" 40 | run: | 41 | python3 -m pip install --upgrade pip 42 | python3 -m pip install setuptools wheel twine 43 | 44 | # Build and upload to PyPI 45 | - name: "Build and upload to PyPI" 46 | run: | 47 | python3 setup.py sdist bdist_wheel 48 | python3 -m twine upload dist/* --verbose 49 | env: 50 | TWINE_USERNAME: __token__ 51 | TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }} 52 | -------------------------------------------------------------------------------- /.github/workflows/sync_and_publish.yml: -------------------------------------------------------------------------------- 1 | name: Sync and publish to PIP 2 | 3 | on: 4 | # Triggers the workflow when a release is created 5 | release: 6 | types: [created] 7 | # Allows you to run this workflow manually from the Actions tab 8 | workflow_dispatch: 9 | 10 | jobs: 11 | # sync submodule repos 12 | sync: 13 | name: 'Submodules Sync' 14 | runs-on: ubuntu-latest 15 | 16 | # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest 17 | defaults: 18 | run: 19 | shell: bash 20 | 21 | steps: 22 | # Checkout the repository to the GitHub Actions runner 23 | - name: Checkout repository 24 | uses: actions/checkout@v2 25 | with: 26 | submodules: true 27 | 28 | # Update submodule 29 | - name: Git Sumbodule Update 30 | run: git submodule update --remote --recursive 31 | 32 | # Commit updates 33 | - name: Commit update 34 | run: | 35 | git config --global user.name 'Git bot' 36 | git config --global user.email 'bot@noreply.github.com' 37 | git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} 38 | git commit -am "Auto updated submodule references" && git push || echo "No changes to commit" 39 | 40 | # upload current state of repo to PIP 41 | upload: 42 | needs: sync 43 | runs-on: ubuntu-latest 44 | steps: 45 | # Checks-out repository under $GITHUB_WORKSPACE 46 | - name: "Checkout repository and submodules" 47 | uses: actions/checkout@v2 48 | with: 49 | submodules: recursive 50 | 51 | # Set up python 52 | - uses: actions/setup-python@v2 53 | with: 54 | python-version: 3.8 55 | 56 | # Set package version number 57 | - name: Set version number to release number 58 | run: | 59 | VERSION=${{github.event.release.tag_name}} 60 | PLACEHOLDER='version="main"' 61 | VERSION_FILE='setup.py' 62 | # ensure the placeholder is there. If grep doesn't find the placeholder 63 | # it exits with exit code 1 and github actions aborts the build. 64 | grep "$PLACEHOLDER" "$VERSION_FILE" 65 | sed -i "s/$PLACEHOLDER/version = \"${VERSION}\"/g" "$VERSION_FILE" 66 | shell: bash 67 | 68 | # Install dependencies 69 | - name: "Install dependencies" 70 | run: | 71 | python3 -m pip install --upgrade pip 72 | python3 -m pip install setuptools wheel twine 73 | # Build and upload to PyPI 74 | - name: "Build and upload to PyPI" 75 | run: | 76 | python3 setup.py sdist bdist_wheel 77 | python3 -m twine upload dist/* --verbose 78 | env: 79 | TWINE_USERNAME: __token__ 80 | TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }} 81 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 105 | __pypackages__/ 106 | 107 | # Celery stuff 108 | celerybeat-schedule 109 | celerybeat.pid 110 | 111 | # SageMath parsed files 112 | *.sage.py 113 | 114 | # Environments 115 | .env 116 | .venv 117 | env/ 118 | venv/ 119 | ENV/ 120 | env.bak/ 121 | venv.bak/ 122 | 123 | # Spyder project settings 124 | .spyderproject 125 | .spyproject 126 | 127 | # Rope project settings 128 | .ropeproject 129 | 130 | # mkdocs documentation 131 | /site 132 | 133 | # mypy 134 | .mypy_cache/ 135 | .dmypy.json 136 | dmypy.json 137 | 138 | # Pyre type checker 139 | .pyre/ 140 | 141 | # pytype static type analyzer 142 | .pytype/ 143 | 144 | # Cython debug symbols 145 | cython_debug/ 146 | 147 | # PyCharm 148 | # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can 149 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 150 | # and can be added to the global gitignore or merged into this file. For a more nuclear 151 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 152 | #.idea/ 153 | --------------------------------------------------------------------------------