mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Merge pull request #378 from stashapp/develop
Merge develop to master for 0.1 release
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
go.mod text eol=lf
|
||||
go.sum text eol=lf
|
||||
4
.github/FUNDING.yml
vendored
4
.github/FUNDING.yml
vendored
@@ -2,11 +2,11 @@
|
||||
|
||||
# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
# patreon: # Replace with a single Patreon username
|
||||
# open_collective: # Replace with a single Open Collective username
|
||||
open_collective: stashapp
|
||||
# ko_fi: # Replace with a single Ko-fi username
|
||||
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: StashApp
|
||||
# liberapay: StashApp
|
||||
# issuehunt: # Replace with a single IssueHunt username
|
||||
# otechie: # Replace with a single Otechie username
|
||||
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
|
||||
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[Bug Report] Short Form Subject (50 Chars or less)"
|
||||
labels: help wanted
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem please ensure that your screenshots are SFW or at least appropriately censored.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
24
.github/ISSUE_TEMPLATE/discussion---request-for-commentary--rfc-.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/discussion---request-for-commentary--rfc-.md
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
name: Discussion / Request for Commentary [RFC]
|
||||
about: This is for issues that will be discussed and won't necessarily result directly
|
||||
in commits or pull requests.
|
||||
title: "[RFC] Short Form Title"
|
||||
labels: help wanted
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Update or delete the title if you need to delegate your title gore to something
|
||||
# Title
|
||||
|
||||
*### Scope*
|
||||
<!-- describe the scope of your topic and your goals ideally within a single paragraph or TL;DR kind of summary so its easier for people to determine if they can contribute at a glance. -->
|
||||
|
||||
## Long Form
|
||||
<!-- Only required if your scope and titles can't cover everything. -->
|
||||
|
||||
## Examples
|
||||
<!-- if you can show a picture or video examples post them here, please ensure that you respect people's time and attention and understand that people are volunteering their time, so concision is ideal and considerate. -->
|
||||
|
||||
## Reference Reading
|
||||
<!-- if there is any reference reading or documentation, please refer to it here. -->
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[Feature] Short Form Title (50 chars or less.)"
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
18
.github/PULL_REQUEST_TEMPLATE/BugFix.md
vendored
Normal file
18
.github/PULL_REQUEST_TEMPLATE/BugFix.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
name: Bug Fix
|
||||
about: Add a bug fix this project!
|
||||
title: "[Bug Fix] Short Form Title (50 chars or less.)"
|
||||
labels: bug
|
||||
assignees: 'WithoutPants, bnkai, Leopere'
|
||||
|
||||
---
|
||||
<!-- Please make sure to read https://github.com/stashapp/stash/docs/CONTRIBUTING.md and check that you understand and have followed it as best as possible -->
|
||||
<!-- Explain what your bugfix seeks to remedy in a short paragraph. -->
|
||||
# Scope
|
||||
|
||||
<!-- Declare any issues by typing `fixes #1` or `closes #1` for example so that the automation can kick in when this is merged -->
|
||||
## Closes/Fixes Issues
|
||||
|
||||
<!-- What have you tested specifically and what possible impacts/areas there are that may need retesting by others. -->
|
||||
## Other testing QA Notes
|
||||
|
||||
17
.github/PULL_REQUEST_TEMPLATE/Feature.md
vendored
Normal file
17
.github/PULL_REQUEST_TEMPLATE/Feature.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Feature Addition
|
||||
about: Add a feature to this project!
|
||||
title: "[Feature] Short Form Title (50 chars or less.)"
|
||||
labels: enhancement
|
||||
assignees: 'WithoutPants, bnkai, Leopere'
|
||||
|
||||
---
|
||||
<!-- Please make sure to read https://github.com/stashapp/stash/docs/CONTRIBUTING.md and check that you understand and have followed it as best as possible
|
||||
Explain what your feature does in a short paragraph. -->
|
||||
# Scope
|
||||
|
||||
<!-- Declare any issues by typing `fixes #1` or `closes #1` for example so that the automation can kick in when this is merged -->
|
||||
## Closes/Fixes Issues
|
||||
|
||||
<!-- What have you tested specifically and what possible impacts/areas there are that may need retesting by others. -->
|
||||
## Other testing QA Notes
|
||||
71
.travis.yml
71
.travis.yml
@@ -9,35 +9,66 @@ env:
|
||||
- GO111MODULE=on
|
||||
before_install:
|
||||
- echo -e "machine github.com\n login $CI_USER_TOKEN" > ~/.netrc
|
||||
- yarn --cwd ui/v2 install
|
||||
- travis_retry yarn --cwd ui/v2 install --frozen-lockfile
|
||||
- make generate
|
||||
- CI=false yarn --cwd ui/v2 build # TODO: Fix warnings
|
||||
#- go get -v github.com/mgechev/revive
|
||||
script:
|
||||
#- make lint
|
||||
#- make vet
|
||||
- go test
|
||||
before_deploy:
|
||||
- docker pull stashappdev/compiler
|
||||
- make it
|
||||
after_success:
|
||||
- docker pull stashapp/compiler:develop
|
||||
- sh ./scripts/cross-compile.sh
|
||||
- git tag -f v0.0.0-alpha
|
||||
- git push -f --tags
|
||||
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh ./scripts/upload-pull-request.sh; fi'
|
||||
before_deploy:
|
||||
# push the latest tag when on the develop branch
|
||||
- if [ "$TRAVIS_BRANCH" = "develop" ]; then git tag -f latest_develop; git push -f --tags; fi
|
||||
- export RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S %Z')
|
||||
- export STASH_VERSION=$(git describe --tags --exclude latest_develop)
|
||||
# set TRAVIS_TAG explcitly to the version so that it doesn't pick up latest_develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master"]; then export TRAVIS_TAG=${STASH_VERSION}; fi
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: tGJ2q62CfPdayid2qEtW2aGRhMgCl3lBXYYQqp3eH0vFgIIf6cs7IDX7YC/x3XKMEQ/iMLZmtCXZvSTqNrD6Sk7MSnt30GIs+4uxIZDnnd8mV5X3K4n4gjD+NAORc4DrQBvUGrYMKJsR5gtkH0nu6diWb1o1If7OiJEuCPRhrmQYcza7NUdABnA9Z2wn2RNUV9Ga33WUCqLMEU5GtNBlfQPiP/khCQrqn/ocR6wUjYut3J6YagzqH4wsfJi3glHyWtowcNIw1LZi5zFxHD/bRBT4Tln7yypkjWNq9eQILA6i6kRUGf7ggyTx26/k8n4tnu+QD0vVh4EcjlThpU/LGyUXzKrrxjRwaDZnM0oYxg5AfHcBuAiAdo0eWnV3lEWRfTJMIVb9MPf4qDmzR4RREfB5OXOxwq3ODeCcJE8sTIMD/wBPZrlqS/QrRpND2gn2X4snkVukN9t9F4CMTFMtVSzFV7TDJW5E5Lq6VEExulteQhs6kcK9NRPNAaLgRQAw7X9kVWfDtiGUP+fE2i8F9Bo8bm7sOT5O5VPMPykx3EgeNg1IqIgMTCsMlhMJT4xBJoQUgmd2wWyf3Ryw+P+sFgdb5Sd7+lFgJBjMUUoOxMxAOiEgdFvCXcr+/Udyz2RdtetU1/6VzXzLPcKOw0wubZeBkISqu7o9gpfdMP9Eq00=
|
||||
file:
|
||||
- dist/stash-osx
|
||||
- dist/stash-win.exe
|
||||
- dist/stash-linux
|
||||
- dist/stash-pi
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
body: ${RELEASE_DATE}
|
||||
on:
|
||||
repo: stashapp/stash
|
||||
branch: master
|
||||
# latest develop release
|
||||
- provider: releases
|
||||
api_key:
|
||||
secure: tGJ2q62CfPdayid2qEtW2aGRhMgCl3lBXYYQqp3eH0vFgIIf6cs7IDX7YC/x3XKMEQ/iMLZmtCXZvSTqNrD6Sk7MSnt30GIs+4uxIZDnnd8mV5X3K4n4gjD+NAORc4DrQBvUGrYMKJsR5gtkH0nu6diWb1o1If7OiJEuCPRhrmQYcza7NUdABnA9Z2wn2RNUV9Ga33WUCqLMEU5GtNBlfQPiP/khCQrqn/ocR6wUjYut3J6YagzqH4wsfJi3glHyWtowcNIw1LZi5zFxHD/bRBT4Tln7yypkjWNq9eQILA6i6kRUGf7ggyTx26/k8n4tnu+QD0vVh4EcjlThpU/LGyUXzKrrxjRwaDZnM0oYxg5AfHcBuAiAdo0eWnV3lEWRfTJMIVb9MPf4qDmzR4RREfB5OXOxwq3ODeCcJE8sTIMD/wBPZrlqS/QrRpND2gn2X4snkVukN9t9F4CMTFMtVSzFV7TDJW5E5Lq6VEExulteQhs6kcK9NRPNAaLgRQAw7X9kVWfDtiGUP+fE2i8F9Bo8bm7sOT5O5VPMPykx3EgeNg1IqIgMTCsMlhMJT4xBJoQUgmd2wWyf3Ryw+P+sFgdb5Sd7+lFgJBjMUUoOxMxAOiEgdFvCXcr+/Udyz2RdtetU1/6VzXzLPcKOw0wubZeBkISqu7o9gpfdMP9Eq00=
|
||||
file:
|
||||
- dist/stash-osx
|
||||
- dist/stash-win.exe
|
||||
- dist/stash-linux
|
||||
- dist/stash-pi
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
name: "${STASH_VERSION}: Latest development build"
|
||||
body: ${RELEASE_DATE}\n This is always the latest committed version on the develop branch. Use as your own risk!
|
||||
prerelease: true
|
||||
on:
|
||||
repo: stashapp/stash
|
||||
branch: develop
|
||||
# official master release - only build when tagged
|
||||
- provider: releases
|
||||
api_key:
|
||||
secure: tGJ2q62CfPdayid2qEtW2aGRhMgCl3lBXYYQqp3eH0vFgIIf6cs7IDX7YC/x3XKMEQ/iMLZmtCXZvSTqNrD6Sk7MSnt30GIs+4uxIZDnnd8mV5X3K4n4gjD+NAORc4DrQBvUGrYMKJsR5gtkH0nu6diWb1o1If7OiJEuCPRhrmQYcza7NUdABnA9Z2wn2RNUV9Ga33WUCqLMEU5GtNBlfQPiP/khCQrqn/ocR6wUjYut3J6YagzqH4wsfJi3glHyWtowcNIw1LZi5zFxHD/bRBT4Tln7yypkjWNq9eQILA6i6kRUGf7ggyTx26/k8n4tnu+QD0vVh4EcjlThpU/LGyUXzKrrxjRwaDZnM0oYxg5AfHcBuAiAdo0eWnV3lEWRfTJMIVb9MPf4qDmzR4RREfB5OXOxwq3ODeCcJE8sTIMD/wBPZrlqS/QrRpND2gn2X4snkVukN9t9F4CMTFMtVSzFV7TDJW5E5Lq6VEExulteQhs6kcK9NRPNAaLgRQAw7X9kVWfDtiGUP+fE2i8F9Bo8bm7sOT5O5VPMPykx3EgeNg1IqIgMTCsMlhMJT4xBJoQUgmd2wWyf3Ryw+P+sFgdb5Sd7+lFgJBjMUUoOxMxAOiEgdFvCXcr+/Udyz2RdtetU1/6VzXzLPcKOw0wubZeBkISqu7o9gpfdMP9Eq00=
|
||||
file:
|
||||
- dist/stash-osx
|
||||
- dist/stash-win.exe
|
||||
- dist/stash-linux
|
||||
- dist/stash-pi
|
||||
# make the release a draft so the maintainers can confirm before releasing
|
||||
draft: true
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
# don't write the body. To be done manually for now. In future we might
|
||||
# want to generate the changelog or get it from a file
|
||||
name: ${STASH_VERSION}
|
||||
on:
|
||||
repo: stashapp/stash
|
||||
branch: master
|
||||
tags: true
|
||||
# make sure we don't release using the latest_develop tag
|
||||
condition: $TRAVIS_TAG != latest_develop
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
674
LICENSE
674
LICENSE
@@ -1,21 +1,661 @@
|
||||
MIT License
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (c) 2019 StashApp
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
19
Makefile
19
Makefile
@@ -3,10 +3,13 @@ ifeq ($(OS),Windows_NT)
|
||||
SET := set
|
||||
endif
|
||||
|
||||
release: generate ui build
|
||||
|
||||
build:
|
||||
$(eval DATE := $(shell go run scripts/getDate.go))
|
||||
$(eval GITHASH := $(shell git rev-parse --short HEAD))
|
||||
$(SET) CGO_ENABLED=1 $(SEPARATOR) go build -mod=vendor -v -ldflags "-X 'github.com/stashapp/stash/pkg/api.buildstamp=$(DATE)' -X 'github.com/stashapp/stash/pkg/api.githash=$(GITHASH)'"
|
||||
$(eval STASH_VERSION := $(shell git describe --tags --exclude latest_develop))
|
||||
$(SET) CGO_ENABLED=1 $(SEPARATOR) go build -mod=vendor -v -ldflags "-X 'github.com/stashapp/stash/pkg/api.version=$(STASH_VERSION)' -X 'github.com/stashapp/stash/pkg/api.buildstamp=$(DATE)' -X 'github.com/stashapp/stash/pkg/api.githash=$(GITHASH)'"
|
||||
|
||||
install:
|
||||
packr2 install
|
||||
@@ -17,7 +20,7 @@ clean:
|
||||
# Regenerates GraphQL files
|
||||
.PHONY: generate
|
||||
generate:
|
||||
go generate
|
||||
go generate -mod=vendor
|
||||
cd ui/v2 && yarn run gqlgen
|
||||
|
||||
# Runs gofmt -w on the project's source code, modifying any files that do not match its style.
|
||||
@@ -28,12 +31,22 @@ fmt:
|
||||
# Runs go vet on the project's source code.
|
||||
.PHONY: vet
|
||||
vet:
|
||||
go vet ./...
|
||||
go vet -mod=vendor ./...
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
revive -config revive.toml -exclude ./vendor/... ./...
|
||||
|
||||
# runs unit tests - excluding integration tests
|
||||
.PHONY: test
|
||||
test:
|
||||
go test -mod=vendor ./...
|
||||
|
||||
# runs all tests - including integration tests
|
||||
.PHONY: it
|
||||
it:
|
||||
go test -mod=vendor -tags=integration ./...
|
||||
|
||||
.PHONY: ui
|
||||
ui:
|
||||
cd ui/v2 && yarn build
|
||||
|
||||
@@ -16,7 +16,7 @@ Follow [this README.md in the docker directory.](docker/production/README.md)
|
||||
|
||||
Stash supports macOS, Windows, and Linux. Download the [latest release here](https://github.com/stashapp/stash/releases).
|
||||
|
||||
Run the executable (double click the exe on windows or run `./stash-osx` / `./stash-linux` from the terminal on macOS / Linux) and navigate to either https://localhost:9999 or http://localhost:9998 to get started.
|
||||
Run the executable (double click the exe on windows or run `./stash-osx` / `./stash-linux` from the terminal on macOS / Linux) and navigate to either https://localhost:9999 or http://localhost:9999 to get started.
|
||||
|
||||
*Note for Windows users:* Running the app might present a security prompt since the binary isn't signed yet. Just click more info and then the "run anyway" button.
|
||||
|
||||
@@ -62,12 +62,14 @@ Join the [Discord server](https://discord.gg/2TsNFKt).
|
||||
|
||||
## Install
|
||||
|
||||
* [Go](https://golang.org/dl/)
|
||||
* [Revive](https://github.com/mgechev/revive) - Configurable linter
|
||||
* Go Install: `go get github.com/mgechev/revive`
|
||||
* [Packr2](https://github.com/gobuffalo/packr/tree/v2.0.2/v2) - Static asset bundler
|
||||
* Go Install: `go get github.com/gobuffalo/packr/v2/packr2@v2.0.2`
|
||||
* [Binary Download](https://github.com/gobuffalo/packr/releases)
|
||||
* [Yarn](https://yarnpkg.com/en/docs/install) - Yarn package manager
|
||||
* Run `yarn install --frozen-lockfile` in the `stash/ui/v2` folder (before running make generate for first time).
|
||||
|
||||
NOTE: You may need to run the `go get` commands outside the project directory to avoid modifying the projects module file.
|
||||
|
||||
@@ -86,6 +88,8 @@ TODO
|
||||
2. Add `GO111MODULE=on`
|
||||
3. Under system variables find the `Path`. Edit and add `C:\Program Files\mingw-w64\*\mingw64\bin` (replace * with the correct path).
|
||||
|
||||
NOTE: The `make` command in Windows will be `mingw32-make` with MingW.
|
||||
|
||||
## Commands
|
||||
|
||||
* `make generate` - Generate Go GraphQL and packr2 files
|
||||
|
||||
55
docker/build/x86_64/Dockerfile
Normal file
55
docker/build/x86_64/Dockerfile
Normal file
@@ -0,0 +1,55 @@
|
||||
# this dockerfile must be built from the top-level stash directory
|
||||
# ie from top=level stash:
|
||||
# docker build -t stash/build -f docker/build/x86_64/Dockerfile .
|
||||
|
||||
FROM golang:1.11.13 as compiler
|
||||
|
||||
RUN apt-get update && apt-get install -y apt-transport-https
|
||||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
|
||||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y nodejs yarn xz-utils --no-install-recommends || exit 1; \
|
||||
rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
ENV PACKR2_VERSION=2.0.2
|
||||
ENV PACKR2_SHA=f95ff4c96d7a28813220df030ad91700b8464fe292ab3e1dc9582305c2a338d2
|
||||
ENV PACKR2_DOWNLOAD_FILE=packr_${PACKR2_VERSION}_linux_amd64.tar.gz
|
||||
ENV PACKR2_DOWNLOAD_URL=https://github.com/gobuffalo/packr/releases/download/v${PACKR2_VERSION}/${PACKR2_DOWNLOAD_FILE}
|
||||
|
||||
WORKDIR /
|
||||
RUN wget ${PACKR2_DOWNLOAD_URL}; \
|
||||
echo "$PACKR2_SHA $PACKR2_DOWNLOAD_FILE" | sha256sum -c - || exit 1; \
|
||||
tar -xzf $PACKR2_DOWNLOAD_FILE -C /usr/bin/ packr2; \
|
||||
rm $PACKR2_DOWNLOAD_FILE;
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
RUN wget -O /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
tar xf /ffmpeg.tar.xz && \
|
||||
rm ffmpeg.tar.xz && \
|
||||
mv /ffmpeg*/ /ffmpeg/
|
||||
|
||||
# copy the ui yarn stuff so that it doesn't get rebuilt every time
|
||||
COPY ./ui/v2/package.json ./ui/v2/yarn.lock /stash/ui/v2/
|
||||
|
||||
WORKDIR /stash
|
||||
RUN yarn --cwd ui/v2 install --frozen-lockfile
|
||||
|
||||
COPY . /stash/
|
||||
ENV GO111MODULE=on
|
||||
|
||||
RUN make generate
|
||||
RUN make ui
|
||||
RUN make build
|
||||
|
||||
FROM ubuntu:19.10 as app
|
||||
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
COPY --from=compiler /stash/stash /ffmpeg/ffmpeg /ffmpeg/ffprobe /usr/bin/
|
||||
|
||||
EXPOSE 9999
|
||||
CMD ["stash"]
|
||||
|
||||
|
||||
67
docker/build/x86_64/README.md
Normal file
67
docker/build/x86_64/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Introduction
|
||||
|
||||
This dockerfile is used to build a stash docker container using the current source code.
|
||||
|
||||
# Building the docker container
|
||||
|
||||
From the top-level directory (should contain `main.go` file):
|
||||
|
||||
```
|
||||
docker build -t stash/build -f ./docker/build/x86_64/Dockerfile .
|
||||
|
||||
```
|
||||
|
||||
# Running the docker container
|
||||
|
||||
## Using docker-compose
|
||||
|
||||
See the `README.md` file in `docker/production` for instructions on how to get docker-compose if needed.
|
||||
|
||||
The `stash/build` container can be run with the `docker-compose.yml` file in `docker/production` by changing the `image` value to be `stash/build`. See the instructions in `docker/production` for how to run docker-compose.
|
||||
|
||||
## Using `docker run`
|
||||
|
||||
After building the container:
|
||||
|
||||
```
|
||||
docker run \
|
||||
-e STASH_STASH=/data/ \
|
||||
-e STASH_METADATA=/metadata/ \
|
||||
-e STASH_CACHE=/cache/ \
|
||||
-e STASH_GENERATED=/generated/ \
|
||||
-v <path to config dir>:/root/.stash \
|
||||
-v <path to media>:/data \
|
||||
-v <path to metadata>:/metadata \
|
||||
-v <path to cache>:/cache \
|
||||
-v <path to generated>:/generated \
|
||||
-p 9999:9999 \
|
||||
stash/build:latest
|
||||
```
|
||||
|
||||
Change the `<xxx>` to the appropriate paths. Note that the `<path to media>` directory should be separate from the cache, generated and metadata directories. It is recommended to have the cache, generated and metadata directories in the same parent directory, for example:
|
||||
|
||||
```
|
||||
/stash
|
||||
/config
|
||||
/metadata
|
||||
/generated
|
||||
/cache
|
||||
/media
|
||||
```
|
||||
|
||||
Using this example directory structure, the above command would be:
|
||||
|
||||
```
|
||||
docker run \
|
||||
-e STASH_STASH=/data/ \
|
||||
-e STASH_METADATA=/metadata/ \
|
||||
-e STASH_CACHE=/cache/ \
|
||||
-e STASH_GENERATED=/generated/ \
|
||||
-v /stash/config:/root/.stash \
|
||||
-v /media:/data \
|
||||
-v /stash/metadata:/metadata \
|
||||
-v /stash/cache:/cache \
|
||||
-v /stash/generated:/generated \
|
||||
-p 9999:9999 \
|
||||
stash/build:latest
|
||||
```
|
||||
21
docker/develop/x86_64/Dockerfile
Normal file
21
docker/develop/x86_64/Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
FROM ubuntu:18.04 as prep
|
||||
LABEL MAINTAINER="https://discord.gg/Uz29ny"
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install curl xz-utils && \
|
||||
apt-get autoclean -y && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
RUN curl -L -o /stash $(curl -s https://api.github.com/repos/stashapp/stash/releases/tags/latest_develop | awk '/browser_download_url/ && /stash-linux/' | sed -e 's/.*: "\(.*\)"/\1/') && \
|
||||
chmod +x /stash && \
|
||||
curl --http1.1 -o /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
tar xf /ffmpeg.tar.xz && \
|
||||
rm ffmpeg.tar.xz && \
|
||||
mv /ffmpeg*/ /ffmpeg/
|
||||
|
||||
FROM ubuntu:18.04 as app
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
COPY --from=prep /stash /ffmpeg/ffmpeg /ffmpeg/ffprobe /usr/bin/
|
||||
EXPOSE 9999
|
||||
CMD ["stash"]
|
||||
@@ -11,7 +11,7 @@ services:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-file: "10"
|
||||
max-size: "200k"
|
||||
max-size: "2m"
|
||||
environment:
|
||||
- STASH_STASH=/data/
|
||||
- STASH_GENERATED=/generated/
|
||||
@@ -19,13 +19,16 @@ services:
|
||||
- STASH_CACHE=/cache/
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
## Adjust below paths (the left part) to your liking.
|
||||
## E.g. you can change ./config:/root/.stash to ./stash:/root/.stash
|
||||
|
||||
## Keep configs here.
|
||||
- ./config:/root/.stash
|
||||
## Point this at your collection.
|
||||
- ./data:/data
|
||||
## This is where pre-generated transcodes live.
|
||||
- ./transcodes:/transcodes
|
||||
## This is where your stash's metadata lives
|
||||
- ./metadata:/metadata
|
||||
## Any other cache content.
|
||||
- ./cache:/cache
|
||||
## Where to store generated content (screenshots,previews,transcodes,sprites)
|
||||
- ./generated:/generated
|
||||
|
||||
@@ -7,17 +7,15 @@ RUN apt-get update && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
RUN curl -L -o /stash $(curl -s https://api.github.com/repos/stashapp/stash/releases | grep -F 'stash-linux' | grep download | head -n 1 | cut -d'"' -f4) && \
|
||||
RUN curl -L -o /stash $(curl -s https://api.github.com/repos/stashapp/stash/releases/latest | awk '/browser_download_url/ && /stash-linux/' | sed -e 's/.*: "\(.*\)"/\1/') && \
|
||||
chmod +x /stash && \
|
||||
curl -o /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
curl --http1.1 -o /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
tar xf /ffmpeg.tar.xz && \
|
||||
rm ffmpeg.tar.xz && \
|
||||
mv /ffmpeg*/ /ffmpeg/
|
||||
|
||||
FROM ubuntu:18.04 as app
|
||||
RUN apt-get update && \
|
||||
apt-get -y install ca-certificates && \
|
||||
adduser stash --gecos GECOS --shell /bin/bash --disabled-password --home /home/stash
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
COPY --from=prep /stash /ffmpeg/ffmpeg /ffmpeg/ffprobe /usr/bin/
|
||||
EXPOSE 9999
|
||||
CMD ["stash"]
|
||||
|
||||
14
docs/CONTRIBUTING.md
Normal file
14
docs/CONTRIBUTING.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
## Technical Debt
|
||||
Please be sure to consider how heavily your contribution impacts the maintainability of the project long term, sometimes less is more. We don't want to merge collossal pull requests with hundreds of dependencies by a driveby contributor.
|
||||
|
||||
## Contributor Checklist
|
||||
Please make sure that you've considered the following before you submit your Pull Requests as ready for merging.
|
||||
* I've run Code linters and [gofmt](https://golang.org/cmd/gofmt/) to make sure that my code is readable.
|
||||
* I have read through formerly submitted [pull requests](https://github.com/stashapp/stash/pulls) and [git issues](https://github.com/stashapp/stash/issues) to make sure that this contribution is required and isn't a duplicate. Also, so that I can manage to close any git Issues needing closed relating to this feature submission.
|
||||
* I commented adequately on my code with the expectation in mind that anyone else should be able to look at this code I've submitted and know exactly what's happening and what the expectations are.
|
||||
|
||||
### Legal Agreements
|
||||
* I acknowledge that if applicable to me, submitting and subsequent acceptance of this Pull Request I, the code contributor of this Pull Request, agree and acknowledge my understanding that the new code license has now been updated to [AGPL](/LICENSE.md). I agree that all code before this Pull Request, which I've previously submitted, is now to be re-licensed under the new license AGPL and no longer the former MIT license.
|
||||
|
||||
**In case you were unable to follow any of the above include an explanation as to why not in your Pull Request.**
|
||||
10
go.mod
10
go.mod
@@ -3,25 +3,31 @@ module github.com/stashapp/stash
|
||||
require (
|
||||
github.com/99designs/gqlgen v0.9.0
|
||||
github.com/PuerkitoBio/goquery v1.5.0
|
||||
github.com/antchfx/htmlquery v1.2.0
|
||||
github.com/antchfx/xpath v1.1.2 // indirect
|
||||
github.com/bmatcuk/doublestar v1.1.5
|
||||
github.com/disintegration/imaging v1.6.0
|
||||
github.com/fsnotify/fsnotify v1.4.7
|
||||
github.com/go-chi/chi v4.0.2+incompatible
|
||||
github.com/gobuffalo/packr/v2 v2.0.2
|
||||
github.com/golang-migrate/migrate/v4 v4.3.1
|
||||
github.com/gorilla/websocket v1.4.0
|
||||
github.com/h2non/filetype v1.0.8
|
||||
// this is required for generate
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/jmoiron/sqlx v1.2.0
|
||||
github.com/mattn/go-sqlite3 v1.10.0
|
||||
github.com/microcosm-cc/bluemonday v1.0.2 // indirect
|
||||
github.com/rs/cors v1.6.0
|
||||
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/spf13/pflag v1.0.3
|
||||
github.com/spf13/viper v1.4.0
|
||||
github.com/vektah/gqlparser v1.1.2
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
|
||||
golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 // indirect
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
)
|
||||
|
||||
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
|
||||
|
||||
go 1.11
|
||||
|
||||
57
go.sum
57
go.sum
@@ -1,18 +1,12 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.28.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.36.0/go.mod h1:RUoy9p/M4ge0HzT8L+SDZ8jg+Q6fth0CiBuhFJpSV40=
|
||||
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
|
||||
contrib.go.opencensus.io/exporter/stackdriver v0.6.0/go.mod h1:QeFzMJDAw8TXt5+aRaSuE8l5BwaMIOIlaVkBOPRuMuw=
|
||||
dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU=
|
||||
dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU=
|
||||
dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
|
||||
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
|
||||
github.com/99designs/gqlgen v0.4.5-0.20190127090136-055fb4bc9a6a h1:oTsAt8YXjEk1fo7uZR7gya1jrH48oPulx5oF6zWTHRw=
|
||||
github.com/99designs/gqlgen v0.4.5-0.20190127090136-055fb4bc9a6a/go.mod h1:st7qHA6ssU3uRZkmv+wzrzgX4srvIqEIdE5iuRW8GhE=
|
||||
github.com/99designs/gqlgen v0.8.2 h1:xOkDPWn/MZjkQ32pu6Axx15mNah0NAq9WalFqT+RavA=
|
||||
github.com/99designs/gqlgen v0.8.2/go.mod h1:aLyJw9xUgdJxZ8EqNQxo2pGFhXXJ/hq8t7J4yn8TgI4=
|
||||
github.com/99designs/gqlgen v0.9.0 h1:g1arBPML74Vqv0L3Q+TqIhGXLspV+2MYtRLkBxuZrlE=
|
||||
github.com/99designs/gqlgen v0.9.0/go.mod h1:HrrG7ic9EgLPsULxsZh/Ti+p0HNWgR3XRuvnD0pb5KY=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
|
||||
@@ -36,16 +30,17 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo
|
||||
github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o=
|
||||
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/antchfx/htmlquery v1.2.0 h1:oKShnsGlnOHX6t4uj5OHgLKkABcJoqnXpqnscoi9Lpw=
|
||||
github.com/antchfx/htmlquery v1.2.0/go.mod h1:MS9yksVSQXls00iXkiMqXr0J+umL/AmxXKuP28SUJM8=
|
||||
github.com/antchfx/xpath v1.1.2 h1:YziPrtM0gEJBnhdUGxYcIVYXZ8FXbtbovxOi+UW/yWQ=
|
||||
github.com/antchfx/xpath v1.1.2/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
|
||||
github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/aws/aws-sdk-go v1.15.54/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
|
||||
github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
|
||||
github.com/bmatcuk/doublestar v1.1.1 h1:YroD6BJCZBYx06yYFEWvUuKVWQn3vLLQAVmDmvTSaiQ=
|
||||
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
||||
github.com/bmatcuk/doublestar v1.1.5 h1:2bNwBOmhyFEFcoB3tGvTD5xanq+4kyOZlB8wFYbMjkk=
|
||||
github.com/bmatcuk/doublestar v1.1.5/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
@@ -97,17 +92,12 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsouza/fake-gcs-server v1.3.0/go.mod h1:Lq+43m2znsXfDKHnQMfdA0HpYYAEJsfizsbpk5k3TLo=
|
||||
github.com/fsouza/fake-gcs-server v1.7.0/go.mod h1:5XIRs4YvwNbNoz+1JF8j6KLAyDh7RHGAyAK3EP2EsNk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-chi/chi v4.0.1+incompatible h1:RSRC5qmFPtO90t7pTL0DBMNpZFsb/sHF3RXVlDgFisA=
|
||||
github.com/go-chi/chi v4.0.1+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=
|
||||
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-ini/ini v1.39.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
@@ -268,6 +258,7 @@ github.com/gobuffalo/packr v1.15.0/go.mod h1:t5gXzEhIviQwVlNx/+3SfS07GS+cZ2hn76W
|
||||
github.com/gobuffalo/packr v1.15.1/go.mod h1:IeqicJ7jm8182yrVmNbM6PR4g79SjN9tZLH8KduZZwE=
|
||||
github.com/gobuffalo/packr v1.19.0/go.mod h1:MstrNkfCQhd5o+Ct4IJ0skWlxN8emOq8DsoT1G98VIU=
|
||||
github.com/gobuffalo/packr v1.20.0/go.mod h1:JDytk1t2gP+my1ig7iI4NcVaXr886+N0ecUga6884zw=
|
||||
github.com/gobuffalo/packr v1.21.0 h1:p2ujcDJQp2QTiYWcI0ByHbr/gMoCouok6M0vXs/yTYQ=
|
||||
github.com/gobuffalo/packr v1.21.0/go.mod h1:H00jGfj1qFKxscFJSw8wcL4hpQtPe1PfU2wa6sg/SR0=
|
||||
github.com/gobuffalo/packr/v2 v2.0.0-rc.8/go.mod h1:y60QCdzwuMwO2R49fdQhsjCPv7tLQFR0ayzxxla9zes=
|
||||
github.com/gobuffalo/packr/v2 v2.0.0-rc.9/go.mod h1:fQqADRfZpEsgkc7c/K7aMew3n4aF1Kji7+lIZeR98Fc=
|
||||
@@ -322,7 +313,6 @@ github.com/gobuffalo/uuid v2.0.5+incompatible/go.mod h1:ErhIzkRhm0FtRuiE/PeORqcw
|
||||
github.com/gobuffalo/validate v2.0.3+incompatible/go.mod h1:N+EtDe0J8252BgfzQUChBgfd6L93m9weay53EWFVsMM=
|
||||
github.com/gobuffalo/x v0.0.0-20181003152136-452098b06085/go.mod h1:WevpGD+5YOreDJznWevcn8NTmQEW5STSBgIkpkjzqXc=
|
||||
github.com/gobuffalo/x v0.0.0-20181007152206-913e47c59ca7/go.mod h1:9rDPXaB3kXdKWzMc4odGQQdG2e2DIEmANy5aSJ9yesY=
|
||||
github.com/gocql/gocql v0.0.0-20181124151448-70385f88b28b/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0=
|
||||
github.com/gocql/gocql v0.0.0-20190301043612-f6df8288f9b4/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0=
|
||||
github.com/gofrs/uuid v3.1.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
@@ -330,11 +320,10 @@ github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang-migrate/migrate/v4 v4.2.2 h1:m9WF3B3yge1mKm5+/q6C3qPETMWqphrod3+osb+sP8A=
|
||||
github.com/golang-migrate/migrate/v4 v4.2.2/go.mod h1:JRwdki93/aFawDXMUM4GcRu/FAIfyw+1Kuyd9vkbaeA=
|
||||
github.com/golang-migrate/migrate/v4 v4.3.1 h1:3eR1NY+pplX+m6yJ1fQf5dFWX3fBgUtZfDiaS/kJVu4=
|
||||
github.com/golang-migrate/migrate/v4 v4.3.1/go.mod h1:mJ89KBgbXmM3P49BqOxRL3riNF/ATlg5kMhm17GA0dE=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef h1:veQD95Isof8w9/WXiA+pa3tz3fJXkt5B7QaRBrM62gk=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
@@ -356,7 +345,6 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI
|
||||
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
|
||||
github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181004151105-1babbf986f6f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
@@ -376,8 +364,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/h2non/filetype v1.0.6 h1:g84/+gdkAT1hnYO+tHpCLoikm13Ju55OkN4KCb1uGEQ=
|
||||
github.com/h2non/filetype v1.0.6/go.mod h1:isekKqOuhMj+s/7r3rIeTErIRy4Rub5uBWHfvMusLMU=
|
||||
github.com/h2non/filetype v1.0.8 h1:le8gpf+FQA0/DlDABbtisA1KiTS0Xi+YSC/E8yY3Y14=
|
||||
github.com/h2non/filetype v1.0.8/go.mod h1:isekKqOuhMj+s/7r3rIeTErIRy4Rub5uBWHfvMusLMU=
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||
@@ -397,7 +383,6 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
|
||||
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ=
|
||||
github.com/jackc/pgx v3.2.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
|
||||
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0/go.mod h1:IiEW3SEiiErVyFdH8NTuWjSifiEQKUoyK3LNqr2kCHU=
|
||||
github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
|
||||
@@ -407,7 +392,6 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||
github.com/karrick/godirwalk v1.7.5/go.mod h1:2c9FRhkDxdIbgkOnCEvnSWs71Bhugbl46shStcFDJ34=
|
||||
@@ -429,7 +413,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kshvakov/clickhouse v1.3.4/go.mod h1:DMzX7FxRymoNkVgizH0DWAL8Cur7wHLgx3MUnGwJqpE=
|
||||
github.com/kshvakov/clickhouse v1.3.5/go.mod h1:DMzX7FxRymoNkVgizH0DWAL8Cur7wHLgx3MUnGwJqpE=
|
||||
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
@@ -470,7 +453,6 @@ github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:F
|
||||
github.com/mitchellh/mapstructure v1.0.0/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mongodb/mongo-go-driver v0.1.0/go.mod h1:NK/HWDIIZkaYsnYa0hmtP443T5ELr0KDecmIioVuuyU=
|
||||
github.com/mongodb/mongo-go-driver v0.3.0/go.mod h1:NK/HWDIIZkaYsnYa0hmtP443T5ELr0KDecmIioVuuyU=
|
||||
github.com/monoculum/formam v0.0.0-20180901015400-4e68be1d79ba/go.mod h1:RKgILGEJq24YyJ2ban8EO0RUVSJlF1pGsEvoLEACr/Q=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
@@ -510,7 +492,6 @@ github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7q
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20180920065004-418d78d0b9a7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
@@ -537,6 +518,8 @@ github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxr
|
||||
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
|
||||
github.com/shurcooL/gofontwoff v0.0.0-20180329035133-29b52fc0a18d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
|
||||
github.com/shurcooL/gopherjslib v0.0.0-20160914041154-feb6d3990c2c/go.mod h1:8d3azKNyqcHP1GaQE/c6dDgjkgSx2BZ4IoEi4F1reUI=
|
||||
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f h1:tygelZueB1EtXkPI6mQ4o9DQ0+FKW41hTbunoXZCTqk=
|
||||
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg=
|
||||
github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:ZpfEhSmds4ytuByIcDnOLkTHGUI6KNqRNPDLHDk+mUU=
|
||||
github.com/shurcooL/highlight_go v0.0.0-20170515013102-78fb10f4a5f8/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag=
|
||||
github.com/shurcooL/highlight_go v0.0.0-20181028180052-98c3abbbae20/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag=
|
||||
@@ -564,8 +547,6 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
|
||||
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
|
||||
@@ -585,8 +566,6 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.2.1/go.mod h1:P4AexN0a+C9tGAnUFNwDMYYZv3pjFuvmeiMyKRaNVlI=
|
||||
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
|
||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -604,10 +583,8 @@ github.com/unrolled/secure v0.0.0-20180918153822-f340ee86eb8b/go.mod h1:mnPT77IA
|
||||
github.com/unrolled/secure v0.0.0-20181005190816-ff9db2ff917f/go.mod h1:mnPT77IAdsi/kV7+Es7y+pXALeV3h7G6dQF6mNYjcLA=
|
||||
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/vektah/dataloaden v0.2.0/go.mod h1:vxM6NuRlgiR0M6wbVTJeKp9vQIs81ZMfCYO+4yq/jbE=
|
||||
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg=
|
||||
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U=
|
||||
github.com/vektah/gqlparser v1.1.0 h1:3668p2gUlO+PiS81x957Rpr3/FPRWG6cxgCXAvTS1hw=
|
||||
github.com/vektah/gqlparser v1.1.0/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
||||
github.com/vektah/gqlparser v1.1.2 h1:ZsyLGn7/7jDNI+y4SEhI4yAxRChlv15pUHMjijT+e68=
|
||||
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
||||
github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs=
|
||||
@@ -617,7 +594,6 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b/go.mod h1:T3BPAOm2cqquPa0MKWeNkmOM5RQsRhkrwMWonFMN7fE=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.opencensus.io v0.17.0/go.mod h1:mp1VrMQxhlqqDpKvH4UcQUa4YwlzNmymAjPrDdfxNpI=
|
||||
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
@@ -658,13 +634,11 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180404174746-b3c676e531a6/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180816102801-aaf60122140d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180925072008-f04abc6bdfa7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -698,6 +672,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -705,7 +680,6 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180921163948-d47a0f339242/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180925112736-b09afc3d579e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180927150500-dad3d9fb7b6e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181005133103-4497e2df6f9e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181011152604-fa43e7bc11ba/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -722,7 +696,6 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190102155601-82a175fd1598/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190108104531-7fbe1cd0fcc2/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190116161447-11f53e031339 h1:g/Jesu8+QLnA0CPzF3E1pURg0Byr7i6jLoX5sqjcAh0=
|
||||
golang.org/x/sys v0.0.0-20190116161447-11f53e031339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -741,7 +714,6 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180924175601-e93be7f42f9f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181003024731-2f84ea8ef872/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181006002542-f60d9635b16a/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181008205924-a2b3f7f249e9/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
@@ -763,7 +735,6 @@ golang.org/x/tools v0.0.0-20181207183836-8bc39b988060/go.mod h1:n7NCudcB/nEzxVGm
|
||||
golang.org/x/tools v0.0.0-20181212172921-837e80568c09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190102213336-ca9055ed7d04/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190104182027-498d95493402/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190108222858-421f03a57a64/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190111214448-fc1d57b08d7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190118193359-16909d206f00 h1:6OmoTtlNJlHuWNIjTEyUtMBHrryp8NRuf/XtnC7MmXM=
|
||||
@@ -782,8 +753,6 @@ golang.org/x/tools v0.0.0-20190425222832-ad9eeb80039a/go.mod h1:RgjU9mgBXZiqYHBn
|
||||
golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd h1:oMEQDWVXVNpceQoVd1JN3CQ7LYJJzs5qWqZIUcxXHHw=
|
||||
golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||
google.golang.org/api v0.0.0-20180921000521-920bb1beccf7/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||
google.golang.org/api v0.0.0-20181015145326-625cd1887957/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||
google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
@@ -794,19 +763,17 @@ google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20180924164928-221a8d4f7494/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
||||
google.golang.org/genproto v0.0.0-20190108161440-ae2f86662275/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
||||
google.golang.org/genproto v0.0.0-20190201180003-4b09977fb922/go.mod h1:L3J43x8/uS+qIUoksaLKe6OS3nUKxOKuIFz1sl2/jx4=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
@@ -823,7 +790,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
|
||||
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/ini.v1 v1.39.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/mail.v2 v2.0.0-20180731213649-a0242b2233b4/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
@@ -834,7 +800,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
|
||||
12
gqlgen.yml
12
gqlgen.yml
@@ -28,3 +28,15 @@ models:
|
||||
model: github.com/stashapp/stash/pkg/models.Studio
|
||||
Tag:
|
||||
model: github.com/stashapp/stash/pkg/models.Tag
|
||||
ScrapedPerformer:
|
||||
model: github.com/stashapp/stash/pkg/models.ScrapedPerformer
|
||||
ScrapedScene:
|
||||
model: github.com/stashapp/stash/pkg/models.ScrapedScene
|
||||
ScrapedScenePerformer:
|
||||
model: github.com/stashapp/stash/pkg/models.ScrapedScenePerformer
|
||||
ScrapedSceneStudio:
|
||||
model: github.com/stashapp/stash/pkg/models.ScrapedSceneStudio
|
||||
ScrapedSceneTag:
|
||||
model: github.com/stashapp/stash/pkg/models.ScrapedSceneTag
|
||||
SceneFileType:
|
||||
model: github.com/stashapp/stash/pkg/models.SceneFileType
|
||||
|
||||
@@ -10,9 +10,15 @@ fragment ConfigGeneralData on ConfigGeneralResult {
|
||||
logOut
|
||||
logLevel
|
||||
logAccess
|
||||
excludes
|
||||
}
|
||||
|
||||
fragment ConfigInterfaceData on ConfigInterfaceResult {
|
||||
soundOnPreview
|
||||
wallShowTitle
|
||||
maximumLoopDuration
|
||||
autostartVideo
|
||||
showStudioAsText
|
||||
css
|
||||
cssEnabled
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ fragment SlimSceneData on Scene {
|
||||
url
|
||||
date
|
||||
rating
|
||||
o_counter
|
||||
path
|
||||
|
||||
file {
|
||||
|
||||
@@ -6,6 +6,7 @@ fragment SceneData on Scene {
|
||||
url
|
||||
date
|
||||
rating
|
||||
o_counter
|
||||
path
|
||||
|
||||
file {
|
||||
|
||||
77
graphql/documents/data/scrapers.graphql
Normal file
77
graphql/documents/data/scrapers.graphql
Normal file
@@ -0,0 +1,77 @@
|
||||
fragment ScrapedPerformerData on ScrapedPerformer {
|
||||
name
|
||||
url
|
||||
twitter
|
||||
instagram
|
||||
birthdate
|
||||
ethnicity
|
||||
country
|
||||
eye_color
|
||||
height
|
||||
measurements
|
||||
fake_tits
|
||||
career_length
|
||||
tattoos
|
||||
piercings
|
||||
aliases
|
||||
}
|
||||
|
||||
fragment ScrapedScenePerformerData on ScrapedScenePerformer {
|
||||
id
|
||||
name
|
||||
url
|
||||
twitter
|
||||
instagram
|
||||
birthdate
|
||||
ethnicity
|
||||
country
|
||||
eye_color
|
||||
height
|
||||
measurements
|
||||
fake_tits
|
||||
career_length
|
||||
tattoos
|
||||
piercings
|
||||
aliases
|
||||
}
|
||||
|
||||
fragment ScrapedSceneStudioData on ScrapedSceneStudio {
|
||||
id
|
||||
name
|
||||
url
|
||||
}
|
||||
|
||||
fragment ScrapedSceneTagData on ScrapedSceneTag {
|
||||
id
|
||||
name
|
||||
}
|
||||
|
||||
fragment ScrapedSceneData on ScrapedScene {
|
||||
title
|
||||
details
|
||||
url
|
||||
date
|
||||
|
||||
file {
|
||||
size
|
||||
duration
|
||||
video_codec
|
||||
audio_codec
|
||||
width
|
||||
height
|
||||
framerate
|
||||
bitrate
|
||||
}
|
||||
|
||||
studio {
|
||||
...ScrapedSceneStudioData
|
||||
}
|
||||
|
||||
tags {
|
||||
...ScrapedSceneTagData
|
||||
}
|
||||
|
||||
performers {
|
||||
...ScrapedScenePerformerData
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ mutation SceneUpdate(
|
||||
$studio_id: ID,
|
||||
$gallery_id: ID,
|
||||
$performer_ids: [ID!] = [],
|
||||
$tag_ids: [ID!] = []) {
|
||||
$tag_ids: [ID!] = [],
|
||||
$cover_image: String) {
|
||||
|
||||
sceneUpdate(input: {
|
||||
id: $id,
|
||||
@@ -20,7 +21,8 @@ mutation SceneUpdate(
|
||||
studio_id: $studio_id,
|
||||
gallery_id: $gallery_id,
|
||||
performer_ids: $performer_ids,
|
||||
tag_ids: $tag_ids
|
||||
tag_ids: $tag_ids,
|
||||
cover_image: $cover_image
|
||||
}) {
|
||||
...SceneData
|
||||
}
|
||||
@@ -60,6 +62,18 @@ mutation ScenesUpdate($input : [SceneUpdateInput!]!) {
|
||||
}
|
||||
}
|
||||
|
||||
mutation SceneIncrementO($id: ID!) {
|
||||
sceneIncrementO(id: $id)
|
||||
}
|
||||
|
||||
mutation SceneDecrementO($id: ID!) {
|
||||
sceneDecrementO(id: $id)
|
||||
}
|
||||
|
||||
mutation SceneResetO($id: ID!) {
|
||||
sceneResetO(id: $id)
|
||||
}
|
||||
|
||||
mutation SceneDestroy($id: ID!, $delete_file: Boolean, $delete_generated : Boolean) {
|
||||
sceneDestroy(input: {id: $id, delete_file: $delete_file, delete_generated: $delete_generated})
|
||||
}
|
||||
@@ -61,7 +61,15 @@ query Logs {
|
||||
}
|
||||
query Version {
|
||||
version {
|
||||
hash,
|
||||
version
|
||||
hash
|
||||
build_time
|
||||
}
|
||||
}
|
||||
|
||||
query LatestVersion {
|
||||
latestversion {
|
||||
shorthash
|
||||
url
|
||||
}
|
||||
}
|
||||
|
||||
51
graphql/documents/queries/scrapers/scrapers.graphql
Normal file
51
graphql/documents/queries/scrapers/scrapers.graphql
Normal file
@@ -0,0 +1,51 @@
|
||||
query ListPerformerScrapers {
|
||||
listPerformerScrapers {
|
||||
id
|
||||
name
|
||||
performer {
|
||||
urls
|
||||
supported_scrapes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query ListSceneScrapers {
|
||||
listSceneScrapers {
|
||||
id
|
||||
name
|
||||
scene {
|
||||
urls
|
||||
supported_scrapes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query ScrapePerformerList($scraper_id: ID!, $query: String!) {
|
||||
scrapePerformerList(scraper_id: $scraper_id, query: $query) {
|
||||
...ScrapedPerformerData
|
||||
}
|
||||
}
|
||||
|
||||
query ScrapePerformer($scraper_id: ID!, $scraped_performer: ScrapedPerformerInput!) {
|
||||
scrapePerformer(scraper_id: $scraper_id, scraped_performer: $scraped_performer) {
|
||||
...ScrapedPerformerData
|
||||
}
|
||||
}
|
||||
|
||||
query ScrapePerformerURL($url: String!) {
|
||||
scrapePerformerURL(url: $url) {
|
||||
...ScrapedPerformerData
|
||||
}
|
||||
}
|
||||
|
||||
query ScrapeScene($scraper_id: ID!, $scene: SceneUpdateInput!) {
|
||||
scrapeScene(scraper_id: $scraper_id, scene: $scene) {
|
||||
...ScrapedSceneData
|
||||
}
|
||||
}
|
||||
|
||||
query ScrapeSceneURL($url: String!) {
|
||||
scrapeSceneURL(url: $url) {
|
||||
...ScrapedSceneData
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@ query MetadataGenerate($input: GenerateMetadataInput!) {
|
||||
metadataGenerate(input: $input)
|
||||
}
|
||||
|
||||
query MetadataAutoTag($input: AutoTagMetadataInput!) {
|
||||
metadataAutoTag(input: $input)
|
||||
}
|
||||
|
||||
query MetadataClean {
|
||||
metadataClean
|
||||
}
|
||||
|
||||
@@ -45,6 +45,20 @@ type Query {
|
||||
|
||||
# Scrapers
|
||||
|
||||
"""List available scrapers"""
|
||||
listPerformerScrapers: [Scraper!]!
|
||||
listSceneScrapers: [Scraper!]!
|
||||
"""Scrape a list of performers based on name"""
|
||||
scrapePerformerList(scraper_id: ID!, query: String!): [ScrapedPerformer!]!
|
||||
"""Scrapes a complete performer record based on a scrapePerformerList result"""
|
||||
scrapePerformer(scraper_id: ID!, scraped_performer: ScrapedPerformerInput!): ScrapedPerformer
|
||||
"""Scrapes a complete performer record based on a URL"""
|
||||
scrapePerformerURL(url: String!): ScrapedPerformer
|
||||
"""Scrapes a complete scene record based on an existing scene"""
|
||||
scrapeScene(scraper_id: ID!, scene: SceneUpdateInput!): ScrapedScene
|
||||
"""Scrapes a complete performer record based on a URL"""
|
||||
scrapeSceneURL(url: String!): ScrapedScene
|
||||
|
||||
"""Scrape a performer using Freeones"""
|
||||
scrapeFreeones(performer_name: String!): ScrapedPerformer
|
||||
"""Scrape a list of performers from a query"""
|
||||
@@ -66,6 +80,8 @@ type Query {
|
||||
metadataScan(input: ScanMetadataInput!): String!
|
||||
"""Start generating content. Returns the job ID"""
|
||||
metadataGenerate(input: GenerateMetadataInput!): String!
|
||||
"""Start auto-tagging. Returns the job ID"""
|
||||
metadataAutoTag(input: AutoTagMetadataInput!): String!
|
||||
"""Clean metadata. Returns the job ID"""
|
||||
metadataClean: String!
|
||||
|
||||
@@ -80,6 +96,9 @@ type Query {
|
||||
|
||||
# Version
|
||||
version: Version!
|
||||
|
||||
# LatestVersion
|
||||
latestversion: ShortVersion!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
@@ -88,6 +107,13 @@ type Mutation {
|
||||
sceneDestroy(input: SceneDestroyInput!): Boolean!
|
||||
scenesUpdate(input: [SceneUpdateInput!]!): [Scene]
|
||||
|
||||
"""Increments the o-counter for a scene. Returns the new value"""
|
||||
sceneIncrementO(id: ID!): Int!
|
||||
"""Decrements the o-counter for a scene. Returns the new value"""
|
||||
sceneDecrementO(id: ID!): Int!
|
||||
"""Resets the o-counter for a scene to 0. Returns the new value"""
|
||||
sceneResetO(id: ID!): Int!
|
||||
|
||||
sceneMarkerCreate(input: SceneMarkerCreateInput!): SceneMarker
|
||||
sceneMarkerUpdate(input: SceneMarkerUpdateInput!): SceneMarker
|
||||
sceneMarkerDestroy(id: ID!): Boolean!
|
||||
|
||||
@@ -30,6 +30,8 @@ input ConfigGeneralInput {
|
||||
logLevel: String!
|
||||
"""Whether to log http access"""
|
||||
logAccess: Boolean!
|
||||
"""Array of file regexp to exclude from Scan"""
|
||||
excludes: [String!]
|
||||
}
|
||||
|
||||
type ConfigGeneralResult {
|
||||
@@ -55,15 +57,37 @@ type ConfigGeneralResult {
|
||||
logLevel: String!
|
||||
"""Whether to log http access"""
|
||||
logAccess: Boolean!
|
||||
"""Array of file regexp to exclude from Scan"""
|
||||
excludes: [String!]!
|
||||
}
|
||||
|
||||
input ConfigInterfaceInput {
|
||||
"""Enable sound on mouseover previews"""
|
||||
soundOnPreview: Boolean
|
||||
"""Show title and tags in wall view"""
|
||||
wallShowTitle: Boolean
|
||||
"""Maximum duration (in seconds) in which a scene video will loop in the scene player"""
|
||||
maximumLoopDuration: Int
|
||||
"""If true, video will autostart on load in the scene player"""
|
||||
autostartVideo: Boolean
|
||||
"""If true, studio overlays will be shown as text instead of logo images"""
|
||||
showStudioAsText: Boolean
|
||||
"""Custom CSS"""
|
||||
css: String
|
||||
cssEnabled: Boolean
|
||||
}
|
||||
|
||||
type ConfigInterfaceResult {
|
||||
"""Enable sound on mouseover previews"""
|
||||
soundOnPreview: Boolean
|
||||
"""Show title and tags in wall view"""
|
||||
wallShowTitle: Boolean
|
||||
"""Maximum duration (in seconds) in which a scene video will loop in the scene player"""
|
||||
maximumLoopDuration: Int
|
||||
"""If true, video will autostart on load in the scene player"""
|
||||
autostartVideo: Boolean
|
||||
"""If true, studio overlays will be shown as text instead of logo images"""
|
||||
showStudioAsText: Boolean
|
||||
"""Custom CSS"""
|
||||
css: String
|
||||
cssEnabled: Boolean
|
||||
|
||||
@@ -62,8 +62,12 @@ input SceneMarkerFilterType {
|
||||
input SceneFilterType {
|
||||
"""Filter by rating"""
|
||||
rating: IntCriterionInput
|
||||
"""Filter by o-counter"""
|
||||
o_counter: IntCriterionInput
|
||||
"""Filter by resolution"""
|
||||
resolution: ResolutionEnum
|
||||
"""Filter by duration (in seconds)"""
|
||||
duration: IntCriterionInput
|
||||
"""Filter to only include scenes which have markers. `true` or `false`"""
|
||||
has_markers: String
|
||||
"""Filter to only include scenes missing this property"""
|
||||
|
||||
@@ -6,7 +6,16 @@ input GenerateMetadataInput {
|
||||
}
|
||||
|
||||
input ScanMetadataInput {
|
||||
nameFromMetadata: Boolean!
|
||||
useFileMetadata: Boolean!
|
||||
}
|
||||
|
||||
input AutoTagMetadataInput {
|
||||
"""IDs of performers to tag files with, or "*" for all"""
|
||||
performers: [String!]
|
||||
"""IDs of studios to tag files with, or "*" for all"""
|
||||
studios: [String!]
|
||||
"""IDs of tags to tag files with, or "*" for all"""
|
||||
tags: [String!]
|
||||
}
|
||||
|
||||
type MetadataUpdateStatus {
|
||||
|
||||
@@ -26,6 +26,7 @@ type Scene {
|
||||
url: String
|
||||
date: String
|
||||
rating: Int
|
||||
o_counter: Int
|
||||
path: String!
|
||||
|
||||
file: SceneFileType! # Resolver
|
||||
@@ -51,6 +52,8 @@ input SceneUpdateInput {
|
||||
gallery_id: ID
|
||||
performer_ids: [ID!]
|
||||
tag_ids: [ID!]
|
||||
"""This should be base64 encoded"""
|
||||
cover_image: String
|
||||
}
|
||||
|
||||
input BulkSceneUpdateInput {
|
||||
|
||||
@@ -16,3 +16,21 @@ type ScrapedPerformer {
|
||||
piercings: String
|
||||
aliases: String
|
||||
}
|
||||
|
||||
input ScrapedPerformerInput {
|
||||
name: String
|
||||
url: String
|
||||
twitter: String
|
||||
instagram: String
|
||||
birthdate: String
|
||||
ethnicity: String
|
||||
country: String
|
||||
eye_color: String
|
||||
height: String
|
||||
measurements: String
|
||||
fake_tits: String
|
||||
career_length: String
|
||||
tattoos: String
|
||||
piercings: String
|
||||
aliases: String
|
||||
}
|
||||
70
graphql/schema/types/scraper.graphql
Normal file
70
graphql/schema/types/scraper.graphql
Normal file
@@ -0,0 +1,70 @@
|
||||
enum ScrapeType {
|
||||
"""From text query"""
|
||||
NAME
|
||||
"""From existing object"""
|
||||
FRAGMENT
|
||||
"""From URL"""
|
||||
URL
|
||||
}
|
||||
|
||||
type ScraperSpec {
|
||||
"""URLs matching these can be scraped with"""
|
||||
urls: [String!]
|
||||
supported_scrapes: [ScrapeType!]!
|
||||
}
|
||||
|
||||
type Scraper {
|
||||
id: ID!
|
||||
name: String!
|
||||
"""Details for performer scraper"""
|
||||
performer: ScraperSpec
|
||||
"""Details for scene scraper"""
|
||||
scene: ScraperSpec
|
||||
}
|
||||
|
||||
|
||||
type ScrapedScenePerformer {
|
||||
"""Set if performer matched"""
|
||||
id: ID
|
||||
name: String!
|
||||
url: String
|
||||
twitter: String
|
||||
instagram: String
|
||||
birthdate: String
|
||||
ethnicity: String
|
||||
country: String
|
||||
eye_color: String
|
||||
height: String
|
||||
measurements: String
|
||||
fake_tits: String
|
||||
career_length: String
|
||||
tattoos: String
|
||||
piercings: String
|
||||
aliases: String
|
||||
}
|
||||
|
||||
type ScrapedSceneStudio {
|
||||
"""Set if studio matched"""
|
||||
id: ID
|
||||
name: String!
|
||||
url: String
|
||||
}
|
||||
|
||||
type ScrapedSceneTag {
|
||||
"""Set if tag matched"""
|
||||
id: ID
|
||||
name: String!
|
||||
}
|
||||
|
||||
type ScrapedScene {
|
||||
title: String
|
||||
details: String
|
||||
url: String
|
||||
date: String
|
||||
|
||||
file: SceneFileType # Resolver
|
||||
|
||||
studio: ScrapedSceneStudio
|
||||
tags: [ScrapedSceneTag!]
|
||||
performers: [ScrapedScenePerformer!]
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
type Version {
|
||||
version: String
|
||||
hash: String!
|
||||
build_time: String!
|
||||
}
|
||||
|
||||
type ShortVersion {
|
||||
shorthash: String!
|
||||
url: String!
|
||||
}
|
||||
|
||||
2
main.go
2
main.go
@@ -1,4 +1,4 @@
|
||||
//go:generate go run github.com/99designs/gqlgen
|
||||
//go:generate go run -mod=vendor github.com/99designs/gqlgen
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
180
pkg/api/check_version.go
Normal file
180
pkg/api/check_version.go
Normal file
@@ -0,0 +1,180 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
)
|
||||
|
||||
//we use the github REST V3 API as no login is required
|
||||
const apiReleases string = "https://api.github.com/repos/stashapp/stash/releases"
|
||||
const apiAcceptHeader string = "application/vnd.github.v3+json"
|
||||
const developmentTag string = "latest_develop"
|
||||
|
||||
var stashReleases = func() map[string]string {
|
||||
return map[string]string{
|
||||
"windows/amd64": "stash-win.exe",
|
||||
"linux/amd64": "stash-linux",
|
||||
"darwin/amd64": "stash-osx",
|
||||
"linux/arm": "stash-pi",
|
||||
}
|
||||
}
|
||||
|
||||
type githubReleasesResponse struct {
|
||||
Url string
|
||||
Assets_url string
|
||||
Upload_url string
|
||||
Html_url string
|
||||
Id int64
|
||||
Node_id string
|
||||
Tag_name string
|
||||
Target_commitish string
|
||||
Name string
|
||||
Draft bool
|
||||
Author githubAuthor
|
||||
Prerelease bool
|
||||
Created_at string
|
||||
Published_at string
|
||||
Assets []githubAsset
|
||||
Tarball_url string
|
||||
Zipball_url string
|
||||
Body string
|
||||
}
|
||||
|
||||
type githubAuthor struct {
|
||||
Login string
|
||||
Id int64
|
||||
Node_id string
|
||||
Avatar_url string
|
||||
Gravatar_id string
|
||||
Url string
|
||||
Html_url string
|
||||
Followers_url string
|
||||
Following_url string
|
||||
Gists_url string
|
||||
Starred_url string
|
||||
Subscriptions_url string
|
||||
Organizations_url string
|
||||
Repos_url string
|
||||
Events_url string
|
||||
Received_events_url string
|
||||
Type string
|
||||
Site_admin bool
|
||||
}
|
||||
|
||||
type githubAsset struct {
|
||||
Url string
|
||||
Id int64
|
||||
Node_id string
|
||||
Name string
|
||||
Label string
|
||||
Uploader githubAuthor
|
||||
Content_type string
|
||||
State string
|
||||
Size int64
|
||||
Download_count int64
|
||||
Created_at string
|
||||
Updated_at string
|
||||
Browser_download_url string
|
||||
}
|
||||
|
||||
// GetLatestVersion gets latest version (git commit hash) from github API
|
||||
// If running a build from the "master" branch, then the latest full release
|
||||
// is used, otherwise it uses the release that is tagged with "latest_develop"
|
||||
// which is the latest pre-release build.
|
||||
func GetLatestVersion(shortHash bool) (latestVersion string, latestRelease string, err error) {
|
||||
|
||||
platform := fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
wantedRelease := stashReleases()[platform]
|
||||
|
||||
version, _, _ := GetVersion()
|
||||
if version == "" {
|
||||
return "", "", fmt.Errorf("Stash doesn't have a version. Version check not supported.")
|
||||
}
|
||||
|
||||
// if the version is suffixed with -x-xxxx, then we are running a development build
|
||||
usePreRelease := false
|
||||
re := regexp.MustCompile(`-\d+-g\w+$`)
|
||||
if re.MatchString(version) {
|
||||
usePreRelease = true
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
url := apiReleases
|
||||
if !usePreRelease {
|
||||
// just get the latest full release
|
||||
url += "/latest"
|
||||
} else {
|
||||
// get the release tagged with the development tag
|
||||
url += "/tags/" + developmentTag
|
||||
}
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
|
||||
req.Header.Add("Accept", apiAcceptHeader) // gh api recommendation , send header with api version
|
||||
response, err := client.Do(req)
|
||||
|
||||
release := githubReleasesResponse{}
|
||||
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("Github API request failed: %s", err)
|
||||
}
|
||||
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return "", "", fmt.Errorf("Github API request failed: %s", response.Status)
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
data, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("Github API read response failed: %s", err)
|
||||
}
|
||||
err = json.Unmarshal(data, &release)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("Unmarshalling Github API response failed: %s", err)
|
||||
}
|
||||
|
||||
if release.Prerelease == usePreRelease {
|
||||
if shortHash {
|
||||
latestVersion = release.Target_commitish[0:7] //shorthash is first 7 digits of git commit hash
|
||||
} else {
|
||||
latestVersion = release.Target_commitish
|
||||
}
|
||||
if wantedRelease != "" {
|
||||
for _, asset := range release.Assets {
|
||||
if asset.Name == wantedRelease {
|
||||
latestRelease = asset.Browser_download_url
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if latestVersion == "" {
|
||||
return "", "", fmt.Errorf("No version found for \"%s\"", version)
|
||||
}
|
||||
return latestVersion, latestRelease, nil
|
||||
}
|
||||
|
||||
func printLatestVersion() {
|
||||
_, githash, _ = GetVersion()
|
||||
latest, _, err := GetLatestVersion(true)
|
||||
if err != nil {
|
||||
logger.Errorf("Couldn't find latest version: %s", err)
|
||||
} else {
|
||||
if githash == latest {
|
||||
logger.Infof("Version: (%s) is already the latest released.", latest)
|
||||
} else {
|
||||
logger.Infof("New version: (%s) available.", latest)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,8 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/scraper"
|
||||
)
|
||||
|
||||
type Resolver struct{}
|
||||
@@ -108,14 +107,30 @@ func (r *queryResolver) Stats(ctx context.Context) (*models.StatsResultType, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) Version(ctx context.Context) (*models.Version, error) {
|
||||
hash, buildtime := GetVersion()
|
||||
version, hash, buildtime := GetVersion()
|
||||
|
||||
return &models.Version{
|
||||
Version: &version,
|
||||
Hash: hash,
|
||||
BuildTime: buildtime,
|
||||
}, nil
|
||||
}
|
||||
|
||||
//Gets latest version (git shorthash commit for now)
|
||||
func (r *queryResolver) Latestversion(ctx context.Context) (*models.ShortVersion, error) {
|
||||
ver, url, err := GetLatestVersion(true)
|
||||
if err == nil {
|
||||
logger.Infof("Retrieved latest hash: %s", ver)
|
||||
} else {
|
||||
logger.Errorf("Error while retrieving latest hash: %s", err)
|
||||
}
|
||||
|
||||
return &models.ShortVersion{
|
||||
Shorthash: ver,
|
||||
URL: url,
|
||||
}, err
|
||||
}
|
||||
|
||||
// Get scene marker tags which show up under the video.
|
||||
func (r *queryResolver) SceneMarkerTags(ctx context.Context, scene_id string) ([]*models.SceneMarkerTag, error) {
|
||||
sceneID, _ := strconv.Atoi(scene_id)
|
||||
@@ -160,14 +175,6 @@ func (r *queryResolver) SceneMarkerTags(ctx context.Context, scene_id string) ([
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *queryResolver) ScrapeFreeones(ctx context.Context, performer_name string) (*models.ScrapedPerformer, error) {
|
||||
return scraper.GetPerformer(performer_name)
|
||||
}
|
||||
|
||||
func (r *queryResolver) ScrapeFreeonesPerformerList(ctx context.Context, query string) ([]string, error) {
|
||||
return scraper.GetPerformerNames(query)
|
||||
}
|
||||
|
||||
// wasFieldIncluded returns true if the given field was included in the request.
|
||||
// Slices are unmarshalled to empty slices even if the field was omitted. This
|
||||
// method determines if it was omitted altogether.
|
||||
|
||||
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/stashapp/stash/pkg/api/urlbuilders"
|
||||
"github.com/stashapp/stash/pkg/manager"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
@@ -64,7 +65,7 @@ func (r *sceneResolver) File(ctx context.Context, obj *models.Scene) (*models.Sc
|
||||
func (r *sceneResolver) Paths(ctx context.Context, obj *models.Scene) (*models.ScenePathsType, error) {
|
||||
baseURL, _ := ctx.Value(BaseURLCtxKey).(string)
|
||||
builder := urlbuilders.NewSceneURLBuilder(baseURL, obj.ID)
|
||||
screenshotPath := builder.GetScreenshotURL()
|
||||
screenshotPath := builder.GetScreenshotURL(obj.UpdatedAt.Timestamp)
|
||||
previewPath := builder.GetStreamPreviewURL()
|
||||
streamPath := builder.GetStreamURL()
|
||||
webpPath := builder.GetStreamPreviewImageURL()
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
@@ -71,14 +72,40 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input models.Co
|
||||
logger.SetLogLevel(input.LogLevel)
|
||||
}
|
||||
|
||||
if input.Excludes != nil {
|
||||
config.Set(config.Exclude, input.Excludes)
|
||||
}
|
||||
|
||||
if err := config.Write(); err != nil {
|
||||
return makeConfigGeneralResult(), err
|
||||
}
|
||||
|
||||
manager.GetInstance().RefreshConfig()
|
||||
|
||||
return makeConfigGeneralResult(), nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) ConfigureInterface(ctx context.Context, input models.ConfigInterfaceInput) (*models.ConfigInterfaceResult, error) {
|
||||
if input.SoundOnPreview != nil {
|
||||
config.Set(config.SoundOnPreview, *input.SoundOnPreview)
|
||||
}
|
||||
|
||||
if input.WallShowTitle != nil {
|
||||
config.Set(config.WallShowTitle, *input.WallShowTitle)
|
||||
}
|
||||
|
||||
if input.MaximumLoopDuration != nil {
|
||||
config.Set(config.MaximumLoopDuration, *input.MaximumLoopDuration)
|
||||
}
|
||||
|
||||
if input.AutostartVideo != nil {
|
||||
config.Set(config.AutostartVideo, *input.AutostartVideo)
|
||||
}
|
||||
|
||||
if input.ShowStudioAsText != nil {
|
||||
config.Set(config.ShowStudioAsText, *input.ShowStudioAsText)
|
||||
}
|
||||
|
||||
css := ""
|
||||
|
||||
if input.CSS != nil {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/stashapp/stash/pkg/database"
|
||||
"github.com/stashapp/stash/pkg/manager"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
|
||||
func (r *mutationResolver) SceneUpdate(ctx context.Context, input models.SceneUpdateInput) (*models.Scene, error) {
|
||||
@@ -59,6 +60,9 @@ func (r *mutationResolver) ScenesUpdate(ctx context.Context, input []*models.Sce
|
||||
func (r *mutationResolver) sceneUpdate(input models.SceneUpdateInput, tx *sqlx.Tx) (*models.Scene, error) {
|
||||
// Populate scene from the input
|
||||
sceneID, _ := strconv.Atoi(input.ID)
|
||||
|
||||
var coverImageData []byte
|
||||
|
||||
updatedTime := time.Now()
|
||||
updatedScene := models.ScenePartial{
|
||||
ID: sceneID,
|
||||
@@ -76,6 +80,14 @@ func (r *mutationResolver) sceneUpdate(input models.SceneUpdateInput, tx *sqlx.T
|
||||
if input.Date != nil {
|
||||
updatedScene.Date = &models.SQLiteDate{String: *input.Date, Valid: true}
|
||||
}
|
||||
if input.CoverImage != nil && *input.CoverImage != "" {
|
||||
var err error
|
||||
_, coverImageData, err = utils.ProcessBase64Image(*input.CoverImage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
updatedScene.Cover = &coverImageData
|
||||
}
|
||||
|
||||
if input.Rating != nil {
|
||||
updatedScene.Rating = &sql.NullInt64{Int64: int64(*input.Rating), Valid: true}
|
||||
@@ -149,6 +161,15 @@ func (r *mutationResolver) sceneUpdate(input models.SceneUpdateInput, tx *sqlx.T
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// only update the cover image if provided and everything else was successful
|
||||
if coverImageData != nil {
|
||||
|
||||
err = manager.SetSceneScreenshot(scene.Checksum, coverImageData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return scene, nil
|
||||
}
|
||||
|
||||
@@ -397,3 +418,63 @@ func changeMarker(ctx context.Context, changeType int, changedMarker models.Scen
|
||||
|
||||
return sceneMarker, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) SceneIncrementO(ctx context.Context, id string) (int, error) {
|
||||
sceneID, _ := strconv.Atoi(id)
|
||||
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
|
||||
newVal, err := qb.IncrementOCounter(sceneID, tx)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Commit
|
||||
if err := tx.Commit(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return newVal, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) SceneDecrementO(ctx context.Context, id string) (int, error) {
|
||||
sceneID, _ := strconv.Atoi(id)
|
||||
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
|
||||
newVal, err := qb.DecrementOCounter(sceneID, tx)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Commit
|
||||
if err := tx.Commit(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return newVal, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) SceneResetO(ctx context.Context, id string) (int, error) {
|
||||
sceneID, _ := strconv.Atoi(id)
|
||||
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
|
||||
newVal, err := qb.ResetOCounter(sceneID, tx)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Commit
|
||||
if err := tx.Commit(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return newVal, nil
|
||||
}
|
||||
|
||||
@@ -45,14 +45,26 @@ func makeConfigGeneralResult() *models.ConfigGeneralResult {
|
||||
LogOut: config.GetLogOut(),
|
||||
LogLevel: config.GetLogLevel(),
|
||||
LogAccess: config.GetLogAccess(),
|
||||
Excludes: config.GetExcludes(),
|
||||
}
|
||||
}
|
||||
|
||||
func makeConfigInterfaceResult() *models.ConfigInterfaceResult {
|
||||
soundOnPreview := config.GetSoundOnPreview()
|
||||
wallShowTitle := config.GetWallShowTitle()
|
||||
maximumLoopDuration := config.GetMaximumLoopDuration()
|
||||
autostartVideo := config.GetAutostartVideo()
|
||||
showStudioAsText := config.GetShowStudioAsText()
|
||||
css := config.GetCSS()
|
||||
cssEnabled := config.GetCSSEnabled()
|
||||
|
||||
return &models.ConfigInterfaceResult{
|
||||
CSS: &css,
|
||||
CSSEnabled: &cssEnabled,
|
||||
SoundOnPreview: &soundOnPreview,
|
||||
WallShowTitle: &wallShowTitle,
|
||||
MaximumLoopDuration: &maximumLoopDuration,
|
||||
AutostartVideo: &autostartVideo,
|
||||
ShowStudioAsText: &showStudioAsText,
|
||||
CSS: &css,
|
||||
CSSEnabled: &cssEnabled,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
|
||||
func (r *queryResolver) FindScene(ctx context.Context, id *string, checksum *string) (*models.Scene, error) {
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
idInt, _ := strconv.Atoi(*id)
|
||||
var scene *models.Scene
|
||||
var err error
|
||||
if id != nil {
|
||||
idInt, _ := strconv.Atoi(*id)
|
||||
scene, err = qb.Find(idInt)
|
||||
} else if checksum != nil {
|
||||
scene, err = qb.FindByChecksum(*checksum)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func (r *queryResolver) MetadataScan(ctx context.Context, input models.ScanMetadataInput) (string, error) {
|
||||
manager.GetInstance().Scan(input.NameFromMetadata)
|
||||
manager.GetInstance().Scan(input.UseFileMetadata)
|
||||
return "todo", nil
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ func (r *queryResolver) MetadataGenerate(ctx context.Context, input models.Gener
|
||||
return "todo", nil
|
||||
}
|
||||
|
||||
func (r *queryResolver) MetadataAutoTag(ctx context.Context, input models.AutoTagMetadataInput) (string, error) {
|
||||
manager.GetInstance().AutoTag(input.Performers, input.Studios, input.Tags)
|
||||
return "todo", nil
|
||||
}
|
||||
|
||||
func (r *queryResolver) MetadataClean(ctx context.Context) (string, error) {
|
||||
manager.GetInstance().Clean()
|
||||
return "todo", nil
|
||||
|
||||
65
pkg/api/resolver_query_scraper.go
Normal file
65
pkg/api/resolver_query_scraper.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/scraper"
|
||||
)
|
||||
|
||||
// deprecated
|
||||
func (r *queryResolver) ScrapeFreeones(ctx context.Context, performer_name string) (*models.ScrapedPerformer, error) {
|
||||
scrapedPerformer := models.ScrapedPerformerInput{
|
||||
Name: &performer_name,
|
||||
}
|
||||
return scraper.GetFreeonesScraper().ScrapePerformer(scrapedPerformer)
|
||||
}
|
||||
|
||||
// deprecated
|
||||
func (r *queryResolver) ScrapeFreeonesPerformerList(ctx context.Context, query string) ([]string, error) {
|
||||
scrapedPerformers, err := scraper.GetFreeonesScraper().ScrapePerformerNames(query)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ret []string
|
||||
for _, v := range scrapedPerformers {
|
||||
name := v.Name
|
||||
ret = append(ret, *name)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (r *queryResolver) ListPerformerScrapers(ctx context.Context) ([]*models.Scraper, error) {
|
||||
return scraper.ListPerformerScrapers()
|
||||
}
|
||||
|
||||
func (r *queryResolver) ListSceneScrapers(ctx context.Context) ([]*models.Scraper, error) {
|
||||
return scraper.ListSceneScrapers()
|
||||
}
|
||||
|
||||
func (r *queryResolver) ScrapePerformerList(ctx context.Context, scraperID string, query string) ([]*models.ScrapedPerformer, error) {
|
||||
if query == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return scraper.ScrapePerformerList(scraperID, query)
|
||||
}
|
||||
|
||||
func (r *queryResolver) ScrapePerformer(ctx context.Context, scraperID string, scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error) {
|
||||
return scraper.ScrapePerformer(scraperID, scrapedPerformer)
|
||||
}
|
||||
|
||||
func (r *queryResolver) ScrapePerformerURL(ctx context.Context, url string) (*models.ScrapedPerformer, error) {
|
||||
return scraper.ScrapePerformerURL(url)
|
||||
}
|
||||
|
||||
func (r *queryResolver) ScrapeScene(ctx context.Context, scraperID string, scene models.SceneUpdateInput) (*models.ScrapedScene, error) {
|
||||
return scraper.ScrapeScene(scraperID, scene)
|
||||
}
|
||||
|
||||
func (r *queryResolver) ScrapeSceneURL(ctx context.Context, url string) (*models.ScrapedScene, error) {
|
||||
return scraper.ScrapeSceneURL(url)
|
||||
}
|
||||
@@ -27,9 +27,16 @@ func (rs galleryRoutes) File(w http.ResponseWriter, r *http.Request) {
|
||||
thumb := r.URL.Query().Get("thumb")
|
||||
w.Header().Add("Cache-Control", "max-age=604800000") // 1 Week
|
||||
if thumb == "true" {
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex))
|
||||
} else {
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex, 200))
|
||||
} else if thumb == "" {
|
||||
_, _ = w.Write(gallery.GetImage(fileIndex))
|
||||
} else {
|
||||
width, err := strconv.ParseInt(thumb, 0, 64)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(400), 400)
|
||||
return
|
||||
}
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex, int(width)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type performerRoutes struct{}
|
||||
@@ -23,6 +26,16 @@ func (rs performerRoutes) Routes() chi.Router {
|
||||
|
||||
func (rs performerRoutes) Image(w http.ResponseWriter, r *http.Request) {
|
||||
performer := r.Context().Value(performerKey).(*models.Performer)
|
||||
etag := fmt.Sprintf("%x", md5.Sum(performer.Image))
|
||||
|
||||
if match := r.Header.Get("If-None-Match"); match != "" {
|
||||
if strings.Contains(match, etag) {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Add("Etag", etag)
|
||||
_, _ = w.Write(performer.Image)
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,33 @@ func (rs sceneRoutes) Webp(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, filepath)
|
||||
}
|
||||
|
||||
func getChapterVttTitle(marker *models.SceneMarker) string {
|
||||
if marker.Title != "" {
|
||||
return marker.Title
|
||||
}
|
||||
|
||||
qb := models.NewTagQueryBuilder()
|
||||
primaryTag, err := qb.Find(marker.PrimaryTagID, nil)
|
||||
if err != nil {
|
||||
// should not happen
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ret := primaryTag.Name
|
||||
|
||||
tags, err := qb.FindBySceneMarkerID(marker.ID, nil)
|
||||
if err != nil {
|
||||
// should not happen
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, t := range tags {
|
||||
ret += ", " + t.Name
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (rs sceneRoutes) ChapterVtt(w http.ResponseWriter, r *http.Request) {
|
||||
scene := r.Context().Value(sceneKey).(*models.Scene)
|
||||
qb := models.NewSceneMarkerQueryBuilder()
|
||||
@@ -121,10 +148,11 @@ func (rs sceneRoutes) ChapterVtt(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
vttLines := []string{"WEBVTT", ""}
|
||||
for _, marker := range sceneMarkers {
|
||||
for i, marker := range sceneMarkers {
|
||||
vttLines = append(vttLines, strconv.Itoa(i+1))
|
||||
time := utils.GetVTTTime(marker.Seconds)
|
||||
vttLines = append(vttLines, time+" --> "+time)
|
||||
vttLines = append(vttLines, marker.Title)
|
||||
vttLines = append(vttLines, getChapterVttTitle(marker))
|
||||
vttLines = append(vttLines, "")
|
||||
}
|
||||
vtt := strings.Join(vttLines, "\n")
|
||||
|
||||
@@ -21,12 +21,14 @@ import (
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/rs/cors"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/manager/paths"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
|
||||
var version string = ""
|
||||
var buildstamp string = ""
|
||||
var githash string = ""
|
||||
|
||||
@@ -127,7 +129,7 @@ func Start() {
|
||||
r.HandleFunc("/setup*", func(w http.ResponseWriter, r *http.Request) {
|
||||
ext := path.Ext(r.URL.Path)
|
||||
if ext == ".html" || ext == "" {
|
||||
data := setupUIBox.Bytes("index.html")
|
||||
data, _ := setupUIBox.Find("index.html")
|
||||
_, _ = w.Write(data)
|
||||
} else {
|
||||
r.URL.Path = strings.Replace(r.URL.Path, "/setup", "", 1)
|
||||
@@ -182,6 +184,8 @@ func Start() {
|
||||
return
|
||||
}
|
||||
|
||||
manager.GetInstance().RefreshConfig()
|
||||
|
||||
http.Redirect(w, r, "/", 301)
|
||||
})
|
||||
|
||||
@@ -189,13 +193,23 @@ func Start() {
|
||||
r.HandleFunc("/*", func(w http.ResponseWriter, r *http.Request) {
|
||||
ext := path.Ext(r.URL.Path)
|
||||
if ext == ".html" || ext == "" {
|
||||
data := uiBox.Bytes("index.html")
|
||||
data, _ := uiBox.Find("index.html")
|
||||
_, _ = w.Write(data)
|
||||
} else {
|
||||
isStatic, _ := path.Match("/static/*/*", r.URL.Path)
|
||||
if isStatic {
|
||||
w.Header().Add("Cache-Control", "max-age=604800000")
|
||||
}
|
||||
http.FileServer(uiBox).ServeHTTP(w, r)
|
||||
}
|
||||
})
|
||||
|
||||
displayHost := config.GetHost()
|
||||
if displayHost == "0.0.0.0" {
|
||||
displayHost = "localhost"
|
||||
}
|
||||
displayAddress := displayHost + ":" + strconv.Itoa(config.GetPort())
|
||||
|
||||
address := config.GetHost() + ":" + strconv.Itoa(config.GetPort())
|
||||
if tlsConfig := makeTLSConfig(); tlsConfig != nil {
|
||||
httpsServer := &http.Server{
|
||||
@@ -206,7 +220,9 @@ func Start() {
|
||||
|
||||
go func() {
|
||||
printVersion()
|
||||
logger.Infof("stash is running on HTTPS at https://" + address + "/")
|
||||
printLatestVersion()
|
||||
logger.Infof("stash is listening on " + address)
|
||||
logger.Infof("stash is running at https://" + displayAddress + "/")
|
||||
logger.Fatal(httpsServer.ListenAndServeTLS("", ""))
|
||||
}()
|
||||
} else {
|
||||
@@ -217,18 +233,24 @@ func Start() {
|
||||
|
||||
go func() {
|
||||
printVersion()
|
||||
logger.Infof("stash is running on HTTP at http://" + address + "/")
|
||||
printLatestVersion()
|
||||
logger.Infof("stash is listening on " + address)
|
||||
logger.Infof("stash is running at http://" + displayAddress + "/")
|
||||
logger.Fatal(server.ListenAndServe())
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func printVersion() {
|
||||
fmt.Printf("stash version: %s (%s)\n", githash, buildstamp)
|
||||
versionString := githash
|
||||
if version != "" {
|
||||
versionString = version + " (" + versionString + ")"
|
||||
}
|
||||
fmt.Printf("stash version: %s - %s\n", versionString, buildstamp)
|
||||
}
|
||||
|
||||
func GetVersion() (string, string) {
|
||||
return githash, buildstamp
|
||||
func GetVersion() (string, string, string) {
|
||||
return version, githash, buildstamp
|
||||
}
|
||||
|
||||
func makeTLSConfig() *tls.Config {
|
||||
@@ -274,6 +296,11 @@ func BaseURLMiddleware(next http.Handler) http.Handler {
|
||||
}
|
||||
baseURL := scheme + "://" + r.Host
|
||||
|
||||
externalHost := config.GetExternalHost()
|
||||
if externalHost != "" {
|
||||
baseURL = externalHost
|
||||
}
|
||||
|
||||
r = r.WithContext(context.WithValue(ctx, BaseURLCtxKey, baseURL))
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package urlbuilders
|
||||
|
||||
import "strconv"
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SceneURLBuilder struct {
|
||||
BaseURL string
|
||||
@@ -30,8 +33,8 @@ func (b SceneURLBuilder) GetSpriteVTTURL() string {
|
||||
return b.BaseURL + "/scene/" + b.SceneID + "_thumbs.vtt"
|
||||
}
|
||||
|
||||
func (b SceneURLBuilder) GetScreenshotURL() string {
|
||||
return b.BaseURL + "/scene/" + b.SceneID + "/screenshot"
|
||||
func (b SceneURLBuilder) GetScreenshotURL(updateTime time.Time) string {
|
||||
return b.BaseURL + "/scene/" + b.SceneID + "/screenshot?" + strconv.FormatInt(updateTime.Unix(), 10)
|
||||
}
|
||||
|
||||
func (b SceneURLBuilder) GetChaptersVTTURL() string {
|
||||
|
||||
@@ -2,6 +2,7 @@ package database
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
@@ -16,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var DB *sqlx.DB
|
||||
var appSchemaVersion uint = 1
|
||||
var appSchemaVersion uint = 3
|
||||
|
||||
const sqlite3Driver = "sqlite3_regexp"
|
||||
|
||||
@@ -38,10 +39,20 @@ func Initialize(databasePath string) {
|
||||
DB = conn
|
||||
}
|
||||
|
||||
func Reset(databasePath string) {
|
||||
_ = DB.Close()
|
||||
_ = os.Remove(databasePath)
|
||||
func Reset(databasePath string) error {
|
||||
err := DB.Close()
|
||||
|
||||
if err != nil {
|
||||
return errors.New("Error closing database: " + err.Error())
|
||||
}
|
||||
|
||||
err = os.Remove(databasePath)
|
||||
if err != nil {
|
||||
return errors.New("Error removing database: " + err.Error())
|
||||
}
|
||||
|
||||
Initialize(databasePath)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Migrate the database
|
||||
@@ -71,6 +82,7 @@ func runMigrations(databasePath string) {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
m.Close()
|
||||
}
|
||||
|
||||
func registerRegexpFunc() {
|
||||
|
||||
1
pkg/database/migrations/2_cover_image.up.sql
Normal file
1
pkg/database/migrations/2_cover_image.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE `scenes` ADD COLUMN `cover` blob;
|
||||
1
pkg/database/migrations/3_o_counter.up.sql
Normal file
1
pkg/database/migrations/3_o_counter.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE `scenes` ADD COLUMN `o_counter` tinyint not null default 0;
|
||||
@@ -17,8 +17,8 @@ func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePre
|
||||
args := []string{
|
||||
"-v", "error",
|
||||
"-ss", strconv.Itoa(options.Time),
|
||||
"-t", "0.75",
|
||||
"-i", probeResult.Path,
|
||||
"-t", "0.75",
|
||||
"-max_muxing_queue_size", "1024", // https://trac.ffmpeg.org/ticket/6375
|
||||
"-y",
|
||||
"-c:v", "libx264",
|
||||
|
||||
@@ -22,12 +22,22 @@ const Password = "password"
|
||||
|
||||
const Database = "database"
|
||||
|
||||
const ScrapersPath = "scrapers_path"
|
||||
const Exclude = "exclude"
|
||||
|
||||
const MaxTranscodeSize = "max_transcode_size"
|
||||
const MaxStreamingTranscodeSize = "max_streaming_transcode_size"
|
||||
|
||||
const Host = "host"
|
||||
const Port = "port"
|
||||
const ExternalHost = "external_host"
|
||||
|
||||
// Interface options
|
||||
const SoundOnPreview = "sound_on_preview"
|
||||
const WallShowTitle = "wall_show_title"
|
||||
const MaximumLoopDuration = "maximum_loop_duration"
|
||||
const AutostartVideo = "autostart_video"
|
||||
const ShowStudioAsText = "show_studio_as_text"
|
||||
const CSSEnabled = "cssEnabled"
|
||||
|
||||
// Logging options
|
||||
@@ -73,6 +83,24 @@ func GetDatabasePath() string {
|
||||
return viper.GetString(Database)
|
||||
}
|
||||
|
||||
func GetDefaultScrapersPath() string {
|
||||
// default to the same directory as the config file
|
||||
configFileUsed := viper.ConfigFileUsed()
|
||||
configDir := filepath.Dir(configFileUsed)
|
||||
|
||||
fn := filepath.Join(configDir, "scrapers")
|
||||
|
||||
return fn
|
||||
}
|
||||
|
||||
func GetExcludes() []string {
|
||||
return viper.GetStringSlice(Exclude)
|
||||
}
|
||||
|
||||
func GetScrapersPath() string {
|
||||
return viper.GetString(ScrapersPath)
|
||||
}
|
||||
|
||||
func GetHost() string {
|
||||
return viper.GetString(Host)
|
||||
}
|
||||
@@ -81,6 +109,10 @@ func GetPort() int {
|
||||
return viper.GetInt(Port)
|
||||
}
|
||||
|
||||
func GetExternalHost() string {
|
||||
return viper.GetString(ExternalHost)
|
||||
}
|
||||
|
||||
func GetMaxTranscodeSize() models.StreamingResolutionEnum {
|
||||
ret := viper.GetString(MaxTranscodeSize)
|
||||
|
||||
@@ -149,6 +181,32 @@ func ValidateCredentials(username string, password string) bool {
|
||||
return username == authUser && err == nil
|
||||
}
|
||||
|
||||
// Interface options
|
||||
func GetSoundOnPreview() bool {
|
||||
viper.SetDefault(SoundOnPreview, true)
|
||||
return viper.GetBool(SoundOnPreview)
|
||||
}
|
||||
|
||||
func GetWallShowTitle() bool {
|
||||
viper.SetDefault(WallShowTitle, true)
|
||||
return viper.GetBool(WallShowTitle)
|
||||
}
|
||||
|
||||
func GetMaximumLoopDuration() int {
|
||||
viper.SetDefault(MaximumLoopDuration, 0)
|
||||
return viper.GetInt(MaximumLoopDuration)
|
||||
}
|
||||
|
||||
func GetAutostartVideo() bool {
|
||||
viper.SetDefault(AutostartVideo, false)
|
||||
return viper.GetBool(AutostartVideo)
|
||||
}
|
||||
|
||||
func GetShowStudioAsText() bool {
|
||||
viper.SetDefault(ShowStudioAsText, false)
|
||||
return viper.GetBool(ShowStudioAsText)
|
||||
}
|
||||
|
||||
func GetCSSPath() string {
|
||||
// use custom.css in the same directory as the config file
|
||||
configFileUsed := viper.ConfigFileUsed()
|
||||
|
||||
89
pkg/manager/exclude_files.go
Normal file
89
pkg/manager/exclude_files.go
Normal file
@@ -0,0 +1,89 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func excludeFiles(files []string, patterns []string) ([]string, int) {
|
||||
if patterns == nil {
|
||||
logger.Infof("No exclude patterns in config")
|
||||
return files, 0
|
||||
} else {
|
||||
var results []string
|
||||
var exclCount int
|
||||
|
||||
fileRegexps := generateRegexps(patterns)
|
||||
|
||||
if len(fileRegexps) == 0 {
|
||||
logger.Infof("Excluded 0 files from scan")
|
||||
return files, 0
|
||||
}
|
||||
|
||||
for i := 0; i < len(files); i++ {
|
||||
if matchFileSimple(files[i], fileRegexps) {
|
||||
logger.Infof("File matched pattern. Excluding:\"%s\"", files[i])
|
||||
exclCount++
|
||||
} else {
|
||||
|
||||
//if pattern doesn't match add file to list
|
||||
results = append(results, files[i])
|
||||
}
|
||||
}
|
||||
logger.Infof("Excluded %d file(s) from scan", exclCount)
|
||||
return results, exclCount
|
||||
}
|
||||
}
|
||||
|
||||
func matchFile(file string, patterns []string) bool {
|
||||
if patterns == nil {
|
||||
logger.Infof("No exclude patterns in config.")
|
||||
|
||||
} else {
|
||||
fileRegexps := generateRegexps(patterns)
|
||||
|
||||
if len(fileRegexps) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, regPattern := range fileRegexps {
|
||||
if regPattern.MatchString(strings.ToLower(file)) {
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func generateRegexps(patterns []string) []*regexp.Regexp {
|
||||
|
||||
var fileRegexps []*regexp.Regexp
|
||||
|
||||
for _, pattern := range patterns {
|
||||
reg, err := regexp.Compile(strings.ToLower(pattern))
|
||||
if err != nil {
|
||||
logger.Errorf("Exclude :%v", err)
|
||||
} else {
|
||||
fileRegexps = append(fileRegexps, reg)
|
||||
}
|
||||
}
|
||||
|
||||
if len(fileRegexps) == 0 {
|
||||
return nil
|
||||
} else {
|
||||
return fileRegexps
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func matchFileSimple(file string, regExps []*regexp.Regexp) bool {
|
||||
for _, regPattern := range regExps {
|
||||
if regPattern.MatchString(strings.ToLower(file)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
91
pkg/manager/exclude_files_test.go
Normal file
91
pkg/manager/exclude_files_test.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var excludeTestFilenames = []string{
|
||||
"/stash/videos/filename.mp4",
|
||||
"/stash/videos/new filename.mp4",
|
||||
"filename sample.mp4",
|
||||
"/stash/videos/exclude/not wanted.webm",
|
||||
"/stash/videos/exclude/not wanted2.webm",
|
||||
"/somewhere/trash/not wanted.wmv",
|
||||
"/disk2/stash/videos/exclude/!!wanted!!.avi",
|
||||
"/disk2/stash/videos/xcl/not wanted.avi",
|
||||
"/stash/videos/partial.file.001.webm",
|
||||
"/stash/videos/partial.file.002.webm",
|
||||
"/stash/videos/partial.file.003.webm",
|
||||
"/stash/videos/sample file sample.mkv",
|
||||
"/stash/videos/.ckRVp1/.still_encoding.mp4",
|
||||
"c:\\stash\\videos\\exclude\\filename windows.mp4",
|
||||
"c:\\stash\\videos\\filename windows.mp4",
|
||||
"\\\\network\\videos\\filename windows network.mp4",
|
||||
"\\\\network\\share\\windows network wanted.mp4",
|
||||
"\\\\network\\share\\windows network wanted sample.mp4",
|
||||
"\\\\network\\private\\windows.network.skip.mp4"}
|
||||
|
||||
var excludeTests = []struct {
|
||||
testPattern []string
|
||||
expected int
|
||||
}{
|
||||
{[]string{"sample\\.mp4$", "trash", "\\.[\\d]{3}\\.webm$"}, 6}, //generic
|
||||
{[]string{"no_match\\.mp4"}, 0}, //no match
|
||||
{[]string{"^/stash/videos/exclude/", "/videos/xcl/"}, 3}, //linux
|
||||
{[]string{"/\\.[[:word:]]+/"}, 1}, //linux hidden dirs (handbrake unraid issue?)
|
||||
{[]string{"c:\\\\stash\\\\videos\\\\exclude"}, 1}, //windows
|
||||
{[]string{"\\/[/invalid"}, 0}, //invalid pattern
|
||||
{[]string{"\\/[/invalid", "sample\\.[[:alnum:]]+$"}, 3}, //invalid pattern but continue
|
||||
{[]string{"^\\\\\\\\network"}, 4}, //windows net share
|
||||
{[]string{"\\\\private\\\\"}, 1}, //windows net share
|
||||
{[]string{"\\\\private\\\\", "sample\\.mp4"}, 3}, //windows net share
|
||||
}
|
||||
|
||||
func TestExcludeFiles(t *testing.T) {
|
||||
for _, test := range excludeTests {
|
||||
err := runExclude(excludeTestFilenames, test.testPattern, test.expected)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runExclude(filenames []string, patterns []string, expCount int) error {
|
||||
|
||||
files, count := excludeFiles(filenames, patterns)
|
||||
|
||||
if count != expCount {
|
||||
return fmt.Errorf("Was expecting %d, found %d", expCount, count)
|
||||
}
|
||||
if len(files) != len(filenames)-expCount {
|
||||
return fmt.Errorf("Returned list should have %d files, not %d ", len(filenames)-expCount, len(files))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestMatchFile(t *testing.T) {
|
||||
for _, test := range excludeTests {
|
||||
err := runMatch(excludeTestFilenames, test.testPattern, test.expected)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runMatch(filenames []string, patterns []string, expCount int) error {
|
||||
count := 0
|
||||
for _, file := range filenames {
|
||||
if matchFile(file, patterns) {
|
||||
logger.Infof("File \"%s\" matched pattern\n", file)
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count != expCount {
|
||||
return fmt.Errorf("Was expecting %d, found %d", expCount, count)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -335,9 +335,15 @@ func (h *sceneHolder) postParse() {
|
||||
}
|
||||
|
||||
func (m parseMapper) parse(scene *models.Scene) *sceneHolder {
|
||||
// perform matching on basename
|
||||
// TODO - may want to handle full path at some point
|
||||
|
||||
// #302 - if the pattern includes a path separator, then include the entire
|
||||
// scene path in the match. Otherwise, use the default behaviour of just
|
||||
// the file's basename
|
||||
// must be double \ because of the regex escaping
|
||||
filename := filepath.Base(scene.Path)
|
||||
if strings.Contains(m.regexString, `\\`) || strings.Contains(m.regexString, "/") {
|
||||
filename = scene.Path
|
||||
}
|
||||
|
||||
result := m.regex.FindStringSubmatch(filename)
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ package manager
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/stashapp/stash/pkg/ffmpeg"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"math"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"github.com/stashapp/stash/pkg/ffmpeg"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
|
||||
type GeneratorInfo struct {
|
||||
@@ -84,7 +85,7 @@ func (g *GeneratorInfo) configure() error {
|
||||
// Something seriously wrong with this file
|
||||
if numberOfFrames == 0 || !utils.IsValidFloat64(framerate) {
|
||||
logger.Errorf(
|
||||
"number of frames or framerate is 0. nb_frames <%s> framerate <%s> duration <%s>",
|
||||
"number of frames or framerate is 0. nb_frames <%s> framerate <%f> duration <%f>",
|
||||
videoStream.NbFrames,
|
||||
framerate,
|
||||
g.VideoFile.Duration,
|
||||
|
||||
@@ -66,15 +66,15 @@ func (g *SpriteGenerator) generateSpriteImage(encoder *ffmpeg.Encoder) error {
|
||||
logger.Infof("[generator] generating sprite image for %s", g.Info.VideoFile.Path)
|
||||
|
||||
// Create `this.chunkCount` thumbnails in the tmp directory
|
||||
stepSize := int(g.Info.VideoFile.Duration / float64(g.Info.ChunkCount))
|
||||
stepSize := g.Info.VideoFile.Duration / float64(g.Info.ChunkCount)
|
||||
for i := 0; i < g.Info.ChunkCount; i++ {
|
||||
time := i * stepSize
|
||||
time := float64(i) * stepSize
|
||||
num := fmt.Sprintf("%.3d", i)
|
||||
filename := "thumbnail" + num + ".jpg"
|
||||
|
||||
options := ffmpeg.ScreenshotOptions{
|
||||
OutputPath: instance.Paths.Generated.GetTmpPath(filename),
|
||||
Time: float64(time),
|
||||
Time: time,
|
||||
Width: 160,
|
||||
}
|
||||
encoder.Screenshot(g.Info.VideoFile, options)
|
||||
|
||||
@@ -10,6 +10,7 @@ const (
|
||||
Generate JobStatus = 4
|
||||
Clean JobStatus = 5
|
||||
Scrape JobStatus = 6
|
||||
AutoTag JobStatus = 7
|
||||
)
|
||||
|
||||
func (s JobStatus) String() string {
|
||||
@@ -26,6 +27,8 @@ func (s JobStatus) String() string {
|
||||
statusMessage = "Scan"
|
||||
case Generate:
|
||||
statusMessage = "Generate"
|
||||
case AutoTag:
|
||||
statusMessage = "Auto Tag"
|
||||
}
|
||||
|
||||
return statusMessage
|
||||
|
||||
@@ -39,6 +39,7 @@ type Scene struct {
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Markers []SceneMarker `json:"markers,omitempty"`
|
||||
File *SceneFile `json:"file,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
CreatedAt models.JSONTime `json:"created_at,omitempty"`
|
||||
UpdatedAt models.JSONTime `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ type singleton struct {
|
||||
var instance *singleton
|
||||
var once sync.Once
|
||||
|
||||
type flagStruct struct {
|
||||
configFilePath string
|
||||
}
|
||||
|
||||
var flags = flagStruct{}
|
||||
|
||||
func GetInstance() *singleton {
|
||||
Initialize()
|
||||
return instance
|
||||
@@ -33,9 +39,9 @@ func GetInstance() *singleton {
|
||||
func Initialize() *singleton {
|
||||
once.Do(func() {
|
||||
_ = utils.EnsureDir(paths.GetConfigDirectory())
|
||||
initFlags()
|
||||
initConfig()
|
||||
initLog()
|
||||
initFlags()
|
||||
initEnvs()
|
||||
instance = &singleton{
|
||||
Status: TaskStatus{Status: Idle, Progress: -1},
|
||||
@@ -43,7 +49,7 @@ func Initialize() *singleton {
|
||||
JSON: &jsonUtils{},
|
||||
}
|
||||
|
||||
instance.refreshConfig()
|
||||
instance.RefreshConfig()
|
||||
|
||||
initFFMPEG()
|
||||
})
|
||||
@@ -55,8 +61,11 @@ func initConfig() {
|
||||
// The config file is called config. Leave off the file extension.
|
||||
viper.SetConfigName("config")
|
||||
|
||||
viper.AddConfigPath("$HOME/.stash") // Look for the config in the home directory
|
||||
if flagConfigFileExists, _ := utils.FileExists(flags.configFilePath); flagConfigFileExists {
|
||||
viper.SetConfigFile(flags.configFilePath)
|
||||
}
|
||||
viper.AddConfigPath(".") // Look for config in the working directory
|
||||
viper.AddConfigPath("$HOME/.stash") // Look for the config in the home directory
|
||||
|
||||
err := viper.ReadInConfig() // Find and read the config file
|
||||
if err != nil { // Handle errors reading the config file
|
||||
@@ -65,12 +74,16 @@ func initConfig() {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
logger.Infof("using config file: %s", viper.ConfigFileUsed())
|
||||
|
||||
viper.SetDefault(config.Database, paths.GetDefaultDatabaseFilePath())
|
||||
|
||||
// Set generated to the metadata path for backwards compat
|
||||
viper.SetDefault(config.Generated, viper.GetString(config.Metadata))
|
||||
|
||||
// Set default scrapers path
|
||||
viper.SetDefault(config.ScrapersPath, config.GetDefaultScrapersPath())
|
||||
|
||||
// Disabling config watching due to race condition issue
|
||||
// See: https://github.com/spf13/viper/issues/174
|
||||
// Changes to the config outside the system will require a restart
|
||||
@@ -88,6 +101,7 @@ func initConfig() {
|
||||
func initFlags() {
|
||||
pflag.IP("host", net.IPv4(0, 0, 0, 0), "ip address for the host")
|
||||
pflag.Int("port", 9999, "port to serve from")
|
||||
pflag.StringVarP(&flags.configFilePath, "config", "c", "", "config file to use")
|
||||
|
||||
pflag.Parse()
|
||||
if err := viper.BindPFlags(pflag.CommandLine); err != nil {
|
||||
@@ -96,13 +110,14 @@ func initFlags() {
|
||||
}
|
||||
|
||||
func initEnvs() {
|
||||
viper.SetEnvPrefix("stash") // will be uppercased automatically
|
||||
viper.BindEnv("host") // STASH_HOST
|
||||
viper.BindEnv("port") // STASH_PORT
|
||||
viper.BindEnv("stash") // STASH_STASH
|
||||
viper.BindEnv("generated") // STASH_GENERATED
|
||||
viper.BindEnv("metadata") // STASH_METADATA
|
||||
viper.BindEnv("cache") // STASH_CACHE
|
||||
viper.SetEnvPrefix("stash") // will be uppercased automatically
|
||||
viper.BindEnv("host") // STASH_HOST
|
||||
viper.BindEnv("port") // STASH_PORT
|
||||
viper.BindEnv("external_host") // STASH_EXTERNAL_HOST
|
||||
viper.BindEnv("stash") // STASH_STASH
|
||||
viper.BindEnv("generated") // STASH_GENERATED
|
||||
viper.BindEnv("metadata") // STASH_METADATA
|
||||
viper.BindEnv("cache") // STASH_CACHE
|
||||
}
|
||||
|
||||
func initFFMPEG() {
|
||||
@@ -131,7 +146,7 @@ func initLog() {
|
||||
logger.Init(config.GetLogFile(), config.GetLogOut(), config.GetLogLevel())
|
||||
}
|
||||
|
||||
func (s *singleton) refreshConfig() {
|
||||
func (s *singleton) RefreshConfig() {
|
||||
s.Paths = paths.NewPaths()
|
||||
if config.IsValid() {
|
||||
_ = utils.EnsureDir(s.Paths.Generated.Screenshots)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bmatcuk/doublestar"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TaskStatus struct {
|
||||
@@ -17,6 +17,8 @@ type TaskStatus struct {
|
||||
Progress float64
|
||||
LastUpdate time.Time
|
||||
stopping bool
|
||||
upTo int
|
||||
total int
|
||||
}
|
||||
|
||||
func (t *TaskStatus) Stop() bool {
|
||||
@@ -34,10 +36,16 @@ func (t *TaskStatus) setProgress(upTo int, total int) {
|
||||
if total == 0 {
|
||||
t.Progress = 1
|
||||
}
|
||||
t.upTo = upTo
|
||||
t.total = total
|
||||
t.Progress = float64(upTo) / float64(total)
|
||||
t.updated()
|
||||
}
|
||||
|
||||
func (t *TaskStatus) incrementProgress() {
|
||||
t.setProgress(t.upTo+1, t.total)
|
||||
}
|
||||
|
||||
func (t *TaskStatus) indefiniteProgress() {
|
||||
t.Progress = -1
|
||||
t.updated()
|
||||
@@ -47,7 +55,7 @@ func (t *TaskStatus) updated() {
|
||||
t.LastUpdate = time.Now()
|
||||
}
|
||||
|
||||
func (s *singleton) Scan(nameFromMetadata bool) {
|
||||
func (s *singleton) Scan(useFileMetadata bool) {
|
||||
if s.Status.Status != Idle {
|
||||
return
|
||||
}
|
||||
@@ -69,6 +77,7 @@ func (s *singleton) Scan(nameFromMetadata bool) {
|
||||
return
|
||||
}
|
||||
|
||||
results, _ = excludeFiles(results, config.GetExcludes())
|
||||
total := len(results)
|
||||
logger.Infof("Starting scan of %d files. %d New files found", total, s.neededScan(results))
|
||||
|
||||
@@ -81,7 +90,7 @@ func (s *singleton) Scan(nameFromMetadata bool) {
|
||||
return
|
||||
}
|
||||
wg.Add(1)
|
||||
task := ScanTask{FilePath: path, NameFromMetadata: nameFromMetadata}
|
||||
task := ScanTask{FilePath: path, UseFileMetadata: useFileMetadata}
|
||||
go task.Start(&wg)
|
||||
wg.Wait()
|
||||
}
|
||||
@@ -156,8 +165,12 @@ func (s *singleton) Generate(sprites bool, previews bool, markers bool, transcod
|
||||
return
|
||||
}
|
||||
totalsNeeded := s.neededGenerate(scenes, sprites, previews, markers, transcodes)
|
||||
logger.Infof("Generating %d sprites %d previews %d markers %d transcodes", totalsNeeded.sprites, totalsNeeded.previews, totalsNeeded.markers, totalsNeeded.transcodes)
|
||||
|
||||
if totalsNeeded == nil {
|
||||
logger.Infof("Taking too long to count content. Skipping...")
|
||||
logger.Infof("Generating content")
|
||||
} else {
|
||||
logger.Infof("Generating %d sprites %d previews %d markers %d transcodes", totalsNeeded.sprites, totalsNeeded.previews, totalsNeeded.markers, totalsNeeded.transcodes)
|
||||
}
|
||||
for i, scene := range scenes {
|
||||
s.Status.setProgress(i, total)
|
||||
if s.Status.stopping {
|
||||
@@ -199,9 +212,176 @@ func (s *singleton) Generate(sprites bool, previews bool, markers bool, transcod
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
logger.Infof("Generate finished")
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *singleton) AutoTag(performerIds []string, studioIds []string, tagIds []string) {
|
||||
if s.Status.Status != Idle {
|
||||
return
|
||||
}
|
||||
s.Status.SetStatus(AutoTag)
|
||||
s.Status.indefiniteProgress()
|
||||
|
||||
go func() {
|
||||
defer s.returnToIdleState()
|
||||
|
||||
// calculate work load
|
||||
performerCount := len(performerIds)
|
||||
studioCount := len(studioIds)
|
||||
tagCount := len(tagIds)
|
||||
|
||||
performerQuery := models.NewPerformerQueryBuilder()
|
||||
studioQuery := models.NewTagQueryBuilder()
|
||||
tagQuery := models.NewTagQueryBuilder()
|
||||
|
||||
const wildcard = "*"
|
||||
var err error
|
||||
if performerCount == 1 && performerIds[0] == wildcard {
|
||||
performerCount, err = performerQuery.Count()
|
||||
if err != nil {
|
||||
logger.Errorf("Error getting performer count: %s", err.Error())
|
||||
}
|
||||
}
|
||||
if studioCount == 1 && studioIds[0] == wildcard {
|
||||
studioCount, err = studioQuery.Count()
|
||||
if err != nil {
|
||||
logger.Errorf("Error getting studio count: %s", err.Error())
|
||||
}
|
||||
}
|
||||
if tagCount == 1 && tagIds[0] == wildcard {
|
||||
tagCount, err = tagQuery.Count()
|
||||
if err != nil {
|
||||
logger.Errorf("Error getting tag count: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
total := performerCount + studioCount + tagCount
|
||||
s.Status.setProgress(0, total)
|
||||
|
||||
s.autoTagPerformers(performerIds)
|
||||
s.autoTagStudios(studioIds)
|
||||
s.autoTagTags(tagIds)
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *singleton) autoTagPerformers(performerIds []string) {
|
||||
performerQuery := models.NewPerformerQueryBuilder()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for _, performerId := range performerIds {
|
||||
var performers []*models.Performer
|
||||
if performerId == "*" {
|
||||
var err error
|
||||
performers, err = performerQuery.All()
|
||||
if err != nil {
|
||||
logger.Errorf("Error querying performers: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
performerIdInt, err := strconv.Atoi(performerId)
|
||||
if err != nil {
|
||||
logger.Errorf("Error parsing performer id %s: %s", performerId, err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
performer, err := performerQuery.Find(performerIdInt)
|
||||
if err != nil {
|
||||
logger.Errorf("Error finding performer id %s: %s", performerId, err.Error())
|
||||
continue
|
||||
}
|
||||
performers = append(performers, performer)
|
||||
}
|
||||
|
||||
for _, performer := range performers {
|
||||
wg.Add(1)
|
||||
task := AutoTagPerformerTask{performer: performer}
|
||||
go task.Start(&wg)
|
||||
wg.Wait()
|
||||
|
||||
s.Status.incrementProgress()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *singleton) autoTagStudios(studioIds []string) {
|
||||
studioQuery := models.NewStudioQueryBuilder()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for _, studioId := range studioIds {
|
||||
var studios []*models.Studio
|
||||
if studioId == "*" {
|
||||
var err error
|
||||
studios, err = studioQuery.All()
|
||||
if err != nil {
|
||||
logger.Errorf("Error querying studios: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
studioIdInt, err := strconv.Atoi(studioId)
|
||||
if err != nil {
|
||||
logger.Errorf("Error parsing studio id %s: %s", studioId, err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
studio, err := studioQuery.Find(studioIdInt, nil)
|
||||
if err != nil {
|
||||
logger.Errorf("Error finding studio id %s: %s", studioId, err.Error())
|
||||
continue
|
||||
}
|
||||
studios = append(studios, studio)
|
||||
}
|
||||
|
||||
for _, studio := range studios {
|
||||
wg.Add(1)
|
||||
task := AutoTagStudioTask{studio: studio}
|
||||
go task.Start(&wg)
|
||||
wg.Wait()
|
||||
|
||||
s.Status.incrementProgress()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *singleton) autoTagTags(tagIds []string) {
|
||||
tagQuery := models.NewTagQueryBuilder()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for _, tagId := range tagIds {
|
||||
var tags []*models.Tag
|
||||
if tagId == "*" {
|
||||
var err error
|
||||
tags, err = tagQuery.All()
|
||||
if err != nil {
|
||||
logger.Errorf("Error querying tags: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
tagIdInt, err := strconv.Atoi(tagId)
|
||||
if err != nil {
|
||||
logger.Errorf("Error parsing tag id %s: %s", tagId, err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
tag, err := tagQuery.Find(tagIdInt, nil)
|
||||
if err != nil {
|
||||
logger.Errorf("Error finding tag id %s: %s", tagId, err.Error())
|
||||
continue
|
||||
}
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
wg.Add(1)
|
||||
task := AutoTagTagTask{tag: tag}
|
||||
go task.Start(&wg)
|
||||
wg.Wait()
|
||||
|
||||
s.Status.incrementProgress()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *singleton) Clean() {
|
||||
if s.Status.Status != Idle {
|
||||
return
|
||||
@@ -236,7 +416,7 @@ func (s *singleton) Clean() {
|
||||
}
|
||||
|
||||
if scene == nil {
|
||||
logger.Errorf("nil scene, skipping generate")
|
||||
logger.Errorf("nil scene, skipping Clean")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -286,6 +466,18 @@ type totalsGenerate struct {
|
||||
func (s *singleton) neededGenerate(scenes []*models.Scene, sprites, previews, markers, transcodes bool) *totalsGenerate {
|
||||
|
||||
var totals totalsGenerate
|
||||
const timeoutSecs = 90 * time.Second
|
||||
|
||||
// create a control channel through which to signal the counting loop when the timeout is reached
|
||||
chTimeout := make(chan struct{})
|
||||
|
||||
//run the timeout function in a separate thread
|
||||
go func() {
|
||||
time.Sleep(timeoutSecs)
|
||||
chTimeout <- struct{}{}
|
||||
}()
|
||||
|
||||
logger.Infof("Counting content to generate...")
|
||||
for _, scene := range scenes {
|
||||
if scene != nil {
|
||||
if sprites {
|
||||
@@ -314,6 +506,13 @@ func (s *singleton) neededGenerate(scenes []*models.Scene, sprites, previews, ma
|
||||
}
|
||||
}
|
||||
}
|
||||
//check for timeout
|
||||
select {
|
||||
case <-chTimeout:
|
||||
return nil
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
return &totals
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
streamingFiles = make(map[string][]*http.ResponseWriter)
|
||||
streamingFiles = make(map[string][]*http.ResponseWriter)
|
||||
streamingFilesMutex = sync.RWMutex{}
|
||||
)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
|
||||
func DestroyScene(sceneID int, tx *sqlx.Tx) (error) {
|
||||
func DestroyScene(sceneID int, tx *sqlx.Tx) error {
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
jqb := models.NewJoinsQueryBuilder()
|
||||
|
||||
|
||||
61
pkg/manager/scene_screenshot.go
Normal file
61
pkg/manager/scene_screenshot.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"os"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
|
||||
// needed to decode other image formats
|
||||
_ "image/gif"
|
||||
_ "image/png"
|
||||
)
|
||||
|
||||
func writeImage(path string, imageData []byte) error {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.Write(imageData)
|
||||
return err
|
||||
}
|
||||
|
||||
func writeThumbnail(path string, thumbnail image.Image) error {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return jpeg.Encode(f, thumbnail, nil)
|
||||
}
|
||||
|
||||
func SetSceneScreenshot(checksum string, imageData []byte) error {
|
||||
thumbPath := instance.Paths.Scene.GetThumbnailScreenshotPath(checksum)
|
||||
normalPath := instance.Paths.Scene.GetScreenshotPath(checksum)
|
||||
|
||||
img, _, err := image.Decode(bytes.NewReader(imageData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// resize to 320 width maintaining aspect ratio, for the thumbnail
|
||||
const width = 320
|
||||
origWidth := img.Bounds().Max.X
|
||||
origHeight := img.Bounds().Max.Y
|
||||
height := width / origWidth * origHeight
|
||||
|
||||
thumbnail := imaging.Resize(img, width, height, imaging.Lanczos)
|
||||
err = writeThumbnail(thumbPath, thumbnail)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = writeImage(normalPath, imageData)
|
||||
|
||||
return err
|
||||
}
|
||||
172
pkg/manager/task_autotag.go
Normal file
172
pkg/manager/task_autotag.go
Normal file
@@ -0,0 +1,172 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/stashapp/stash/pkg/database"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
type AutoTagPerformerTask struct {
|
||||
performer *models.Performer
|
||||
}
|
||||
|
||||
func (t *AutoTagPerformerTask) Start(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
t.autoTagPerformer()
|
||||
}
|
||||
|
||||
func getQueryRegex(name string) string {
|
||||
const separatorChars = `.\-_ `
|
||||
// handle path separators
|
||||
const endSeparatorChars = separatorChars + `\\/`
|
||||
const separator = `[` + separatorChars + `]`
|
||||
const endSeparator = `[` + endSeparatorChars + `]`
|
||||
|
||||
ret := strings.Replace(name, " ", separator+"*", -1)
|
||||
ret = "(?:^|" + endSeparator + "+)" + ret + "(?:$|" + endSeparator + "+)"
|
||||
return ret
|
||||
}
|
||||
|
||||
func (t *AutoTagPerformerTask) autoTagPerformer() {
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
jqb := models.NewJoinsQueryBuilder()
|
||||
|
||||
regex := getQueryRegex(t.performer.Name.String)
|
||||
|
||||
scenes, err := qb.QueryAllByPathRegex(regex)
|
||||
|
||||
if err != nil {
|
||||
logger.Infof("Error querying scenes with regex '%s': %s", regex, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
|
||||
for _, scene := range scenes {
|
||||
added, err := jqb.AddPerformerScene(scene.ID, t.performer.ID, tx)
|
||||
|
||||
if err != nil {
|
||||
logger.Infof("Error adding performer '%s' to scene '%s': %s", t.performer.Name.String, scene.GetTitle(), err.Error())
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
if added {
|
||||
logger.Infof("Added performer '%s' to scene '%s'", t.performer.Name.String, scene.GetTitle())
|
||||
}
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
logger.Infof("Error adding performer to scene: %s", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
type AutoTagStudioTask struct {
|
||||
studio *models.Studio
|
||||
}
|
||||
|
||||
func (t *AutoTagStudioTask) Start(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
t.autoTagStudio()
|
||||
}
|
||||
|
||||
func (t *AutoTagStudioTask) autoTagStudio() {
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
|
||||
regex := getQueryRegex(t.studio.Name.String)
|
||||
|
||||
scenes, err := qb.QueryAllByPathRegex(regex)
|
||||
|
||||
if err != nil {
|
||||
logger.Infof("Error querying scenes with regex '%s': %s", regex, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
|
||||
for _, scene := range scenes {
|
||||
// #306 - don't overwrite studio if already present
|
||||
if scene.StudioID.Valid {
|
||||
// don't modify
|
||||
continue
|
||||
}
|
||||
|
||||
logger.Infof("Adding studio '%s' to scene '%s'", t.studio.Name.String, scene.GetTitle())
|
||||
|
||||
// set the studio id
|
||||
studioID := sql.NullInt64{Int64: int64(t.studio.ID), Valid: true}
|
||||
scenePartial := models.ScenePartial{
|
||||
ID: scene.ID,
|
||||
StudioID: &studioID,
|
||||
}
|
||||
|
||||
_, err := qb.Update(scenePartial, tx)
|
||||
|
||||
if err != nil {
|
||||
logger.Infof("Error adding studio to scene: %s", err.Error())
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
logger.Infof("Error adding studio to scene: %s", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
type AutoTagTagTask struct {
|
||||
tag *models.Tag
|
||||
}
|
||||
|
||||
func (t *AutoTagTagTask) Start(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
t.autoTagTag()
|
||||
}
|
||||
|
||||
func (t *AutoTagTagTask) autoTagTag() {
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
jqb := models.NewJoinsQueryBuilder()
|
||||
|
||||
regex := getQueryRegex(t.tag.Name)
|
||||
|
||||
scenes, err := qb.QueryAllByPathRegex(regex)
|
||||
|
||||
if err != nil {
|
||||
logger.Infof("Error querying scenes with regex '%s': %s", regex, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
|
||||
for _, scene := range scenes {
|
||||
added, err := jqb.AddSceneTag(scene.ID, t.tag.ID, tx)
|
||||
|
||||
if err != nil {
|
||||
logger.Infof("Error adding tag '%s' to scene '%s': %s", t.tag.Name, scene.GetTitle(), err.Error())
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
if added {
|
||||
logger.Infof("Added tag '%s' to scene '%s'", t.tag.Name, scene.GetTitle())
|
||||
}
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
logger.Infof("Error adding tag to scene: %s", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
366
pkg/manager/task_autotag_test.go
Normal file
366
pkg/manager/task_autotag_test.go
Normal file
@@ -0,0 +1,366 @@
|
||||
// +build integration
|
||||
|
||||
package manager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stashapp/stash/pkg/database"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
|
||||
_ "github.com/golang-migrate/migrate/v4/database/sqlite3"
|
||||
_ "github.com/golang-migrate/migrate/v4/source/file"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
const testName = "Foo's Bar"
|
||||
const testExtension = ".mp4"
|
||||
const existingStudioName = "ExistingStudio"
|
||||
|
||||
const existingStudioSceneName = testName + ".dontChangeStudio" + testExtension
|
||||
|
||||
var existingStudioID int
|
||||
|
||||
var testSeparators = []string{
|
||||
".",
|
||||
"-",
|
||||
"_",
|
||||
" ",
|
||||
}
|
||||
|
||||
func generateNamePatterns(name string, separator string) []string {
|
||||
var ret []string
|
||||
ret = append(ret, fmt.Sprintf("%s%saaa"+testExtension, name, separator))
|
||||
ret = append(ret, fmt.Sprintf("aaa%s%s"+testExtension, separator, name))
|
||||
ret = append(ret, fmt.Sprintf("aaa%s%s%sbbb"+testExtension, separator, name, separator))
|
||||
ret = append(ret, fmt.Sprintf("dir/%s%saaa"+testExtension, name, separator))
|
||||
ret = append(ret, fmt.Sprintf("dir\\%s%saaa"+testExtension, name, separator))
|
||||
ret = append(ret, fmt.Sprintf("%s%saaa/dir/bbb"+testExtension, name, separator))
|
||||
ret = append(ret, fmt.Sprintf("%s%saaa\\dir\\bbb"+testExtension, name, separator))
|
||||
ret = append(ret, fmt.Sprintf("dir/%s%s/aaa"+testExtension, name, separator))
|
||||
ret = append(ret, fmt.Sprintf("dir\\%s%s\\aaa"+testExtension, name, separator))
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func generateFalseNamePattern(name string, separator string) string {
|
||||
splitted := strings.Split(name, " ")
|
||||
|
||||
return fmt.Sprintf("%s%saaa%s%s"+testExtension, splitted[0], separator, separator, splitted[1])
|
||||
}
|
||||
|
||||
func testTeardown(databaseFile string) {
|
||||
err := database.DB.Close()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = os.Remove(databaseFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func runTests(m *testing.M) int {
|
||||
// create the database file
|
||||
f, err := ioutil.TempFile("", "*.sqlite")
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Could not create temporary file: %s", err.Error()))
|
||||
}
|
||||
|
||||
f.Close()
|
||||
databaseFile := f.Name()
|
||||
database.Initialize(databaseFile)
|
||||
|
||||
// defer close and delete the database
|
||||
defer testTeardown(databaseFile)
|
||||
|
||||
err = populateDB()
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Could not populate database: %s", err.Error()))
|
||||
} else {
|
||||
// run the tests
|
||||
return m.Run()
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
ret := runTests(m)
|
||||
os.Exit(ret)
|
||||
}
|
||||
|
||||
func createPerformer(tx *sqlx.Tx) error {
|
||||
// create the performer
|
||||
pqb := models.NewPerformerQueryBuilder()
|
||||
|
||||
performer := models.Performer{
|
||||
Image: []byte{0, 1, 2},
|
||||
Checksum: testName,
|
||||
Name: sql.NullString{Valid: true, String: testName},
|
||||
Favorite: sql.NullBool{Valid: true, Bool: false},
|
||||
}
|
||||
|
||||
_, err := pqb.Create(performer, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createStudio(tx *sqlx.Tx, name string) (*models.Studio, error) {
|
||||
// create the studio
|
||||
qb := models.NewStudioQueryBuilder()
|
||||
|
||||
studio := models.Studio{
|
||||
Image: []byte{0, 1, 2},
|
||||
Checksum: name,
|
||||
Name: sql.NullString{Valid: true, String: testName},
|
||||
}
|
||||
|
||||
return qb.Create(studio, tx)
|
||||
}
|
||||
|
||||
func createTag(tx *sqlx.Tx) error {
|
||||
// create the studio
|
||||
qb := models.NewTagQueryBuilder()
|
||||
|
||||
tag := models.Tag{
|
||||
Name: testName,
|
||||
}
|
||||
|
||||
_, err := qb.Create(tag, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createScenes(tx *sqlx.Tx) error {
|
||||
sqb := models.NewSceneQueryBuilder()
|
||||
|
||||
// create the scenes
|
||||
var scenePatterns []string
|
||||
var falseScenePatterns []string
|
||||
for _, separator := range testSeparators {
|
||||
scenePatterns = append(scenePatterns, generateNamePatterns(testName, separator)...)
|
||||
scenePatterns = append(scenePatterns, generateNamePatterns(strings.ToLower(testName), separator)...)
|
||||
if separator != " " {
|
||||
scenePatterns = append(scenePatterns, generateNamePatterns(strings.Replace(testName, " ", separator, -1), separator)...)
|
||||
}
|
||||
falseScenePatterns = append(falseScenePatterns, generateFalseNamePattern(testName, separator))
|
||||
}
|
||||
|
||||
for _, fn := range scenePatterns {
|
||||
err := createScene(sqb, tx, makeScene(fn, true))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for _, fn := range falseScenePatterns {
|
||||
err := createScene(sqb, tx, makeScene(fn, false))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// create scene with existing studio io
|
||||
studioScene := makeScene(existingStudioSceneName, true)
|
||||
studioScene.StudioID = sql.NullInt64{Valid: true, Int64: int64(existingStudioID)}
|
||||
err := createScene(sqb, tx, studioScene)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeScene(name string, expectedResult bool) *models.Scene {
|
||||
scene := &models.Scene{
|
||||
Checksum: utils.MD5FromString(name),
|
||||
Path: name,
|
||||
}
|
||||
|
||||
// if expectedResult is true then we expect it to match, set the title accordingly
|
||||
if expectedResult {
|
||||
scene.Title = sql.NullString{Valid: true, String: name}
|
||||
}
|
||||
|
||||
return scene
|
||||
}
|
||||
|
||||
func createScene(sqb models.SceneQueryBuilder, tx *sqlx.Tx, scene *models.Scene) error {
|
||||
_, err := sqb.Create(*scene, tx)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create scene with name '%s': %s", scene.Path, err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateDB() error {
|
||||
ctx := context.TODO()
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
|
||||
err := createPerformer(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = createStudio(tx, testName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create existing studio
|
||||
existingStudio, err := createStudio(tx, existingStudioName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
existingStudioID = existingStudio.ID
|
||||
|
||||
err = createTag(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = createScenes(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestParsePerformers(t *testing.T) {
|
||||
pqb := models.NewPerformerQueryBuilder()
|
||||
performers, err := pqb.All()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error getting performer: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
task := AutoTagPerformerTask{
|
||||
performer: performers[0],
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
task.Start(&wg)
|
||||
|
||||
// verify that scenes were tagged correctly
|
||||
sqb := models.NewSceneQueryBuilder()
|
||||
|
||||
scenes, err := sqb.All()
|
||||
|
||||
for _, scene := range scenes {
|
||||
performers, err := pqb.FindBySceneID(scene.ID, nil)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error getting scene performers: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// title is only set on scenes where we expect performer to be set
|
||||
if scene.Title.String == scene.Path && len(performers) == 0 {
|
||||
t.Errorf("Did not set performer '%s' for path '%s'", testName, scene.Path)
|
||||
} else if scene.Title.String != scene.Path && len(performers) > 0 {
|
||||
t.Errorf("Incorrectly set performer '%s' for path '%s'", testName, scene.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseStudios(t *testing.T) {
|
||||
studioQuery := models.NewStudioQueryBuilder()
|
||||
studios, err := studioQuery.All()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error getting studio: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
task := AutoTagStudioTask{
|
||||
studio: studios[0],
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
task.Start(&wg)
|
||||
|
||||
// verify that scenes were tagged correctly
|
||||
sqb := models.NewSceneQueryBuilder()
|
||||
|
||||
scenes, err := sqb.All()
|
||||
|
||||
for _, scene := range scenes {
|
||||
// check for existing studio id scene first
|
||||
if scene.Path == existingStudioSceneName {
|
||||
if scene.StudioID.Int64 != int64(existingStudioID) {
|
||||
t.Error("Incorrectly overwrote studio ID for scene with existing studio ID")
|
||||
}
|
||||
} else {
|
||||
// title is only set on scenes where we expect studio to be set
|
||||
if scene.Title.String == scene.Path && scene.StudioID.Int64 != int64(studios[0].ID) {
|
||||
t.Errorf("Did not set studio '%s' for path '%s'", testName, scene.Path)
|
||||
} else if scene.Title.String != scene.Path && scene.StudioID.Int64 == int64(studios[0].ID) {
|
||||
t.Errorf("Incorrectly set studio '%s' for path '%s'", testName, scene.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseTags(t *testing.T) {
|
||||
tagQuery := models.NewTagQueryBuilder()
|
||||
tags, err := tagQuery.All()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error getting performer: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
task := AutoTagTagTask{
|
||||
tag: tags[0],
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
task.Start(&wg)
|
||||
|
||||
// verify that scenes were tagged correctly
|
||||
sqb := models.NewSceneQueryBuilder()
|
||||
|
||||
scenes, err := sqb.All()
|
||||
|
||||
for _, scene := range scenes {
|
||||
tags, err := tagQuery.FindBySceneID(scene.ID, nil)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error getting scene tags: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// title is only set on scenes where we expect performer to be set
|
||||
if scene.Title.String == scene.Path && len(tags) == 0 {
|
||||
t.Errorf("Did not set tag '%s' for path '%s'", testName, scene.Path)
|
||||
} else if scene.Title.String != scene.Path && len(tags) > 0 {
|
||||
t.Errorf("Incorrectly set tag '%s' for path '%s'", testName, scene.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,12 @@ func (t *CleanTask) Start(wg *sync.WaitGroup) {
|
||||
|
||||
if t.fileExists(t.Scene.Path) && t.pathInStash() {
|
||||
logger.Debugf("File Found: %s", t.Scene.Path)
|
||||
if matchFile(t.Scene.Path, config.GetExcludes()) {
|
||||
logger.Infof("File matched regex. Cleaning: \"%s\"", t.Scene.Path)
|
||||
t.deleteScene(t.Scene.ID)
|
||||
}
|
||||
} else {
|
||||
logger.Infof("File not found. Cleaning: %s", t.Scene.Path)
|
||||
logger.Infof("File not found. Cleaning: \"%s\"", t.Scene.Path)
|
||||
t.deleteScene(t.Scene.ID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +161,10 @@ func (t *ExportTask) ExportScenes(ctx context.Context) {
|
||||
newSceneJSON.File.Bitrate = int(scene.Bitrate.Int64)
|
||||
}
|
||||
|
||||
if len(scene.Cover) > 0 {
|
||||
newSceneJSON.Cover = utils.GetBase64StringFromData(scene.Cover)
|
||||
}
|
||||
|
||||
sceneJSON, err := instance.JSON.getScene(scene.Checksum)
|
||||
if err != nil {
|
||||
logger.Debugf("[scenes] error reading scene json: %s", err.Error())
|
||||
|
||||
@@ -3,6 +3,10 @@ package manager
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/stashapp/stash/pkg/database"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
@@ -10,9 +14,6 @@ import (
|
||||
"github.com/stashapp/stash/pkg/manager/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ImportTask struct {
|
||||
@@ -34,7 +35,12 @@ func (t *ImportTask) Start(wg *sync.WaitGroup) {
|
||||
}
|
||||
t.Scraped = scraped
|
||||
|
||||
database.Reset(config.GetDatabasePath())
|
||||
err := database.Reset(config.GetDatabasePath())
|
||||
|
||||
if err != nil {
|
||||
logger.Errorf("Error resetting database: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
@@ -376,6 +382,21 @@ func (t *ImportTask) ImportScenes(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Process the base 64 encoded cover image string
|
||||
if sceneJSON.Cover != "" {
|
||||
_, coverImageData, err := utils.ProcessBase64Image(sceneJSON.Cover)
|
||||
if err != nil {
|
||||
logger.Warnf("[scenes] <%s> invalid cover image: %s", mappingJSON.Checksum, err.Error())
|
||||
}
|
||||
if len(coverImageData) > 0 {
|
||||
if err = SetSceneScreenshot(mappingJSON.Checksum, coverImageData); err != nil {
|
||||
logger.Warnf("[scenes] <%s> failed to create cover image: %s", mappingJSON.Checksum, err.Error())
|
||||
} else {
|
||||
newScene.Cover = coverImageData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Populate scene fields
|
||||
if sceneJSON != nil {
|
||||
if sceneJSON.Title != "" {
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
)
|
||||
|
||||
type ScanTask struct {
|
||||
FilePath string
|
||||
NameFromMetadata bool
|
||||
FilePath string
|
||||
UseFileMetadata bool
|
||||
}
|
||||
|
||||
func (t *ScanTask) Start(wg *sync.WaitGroup) {
|
||||
@@ -92,8 +92,8 @@ func (t *ScanTask) scanScene() {
|
||||
return
|
||||
}
|
||||
|
||||
// Override title to be filename if nameFromMetadata is false
|
||||
if !t.NameFromMetadata {
|
||||
// Override title to be filename if UseFileMetadata is false
|
||||
if !t.UseFileMetadata {
|
||||
videoFile.SetTitleFromPath()
|
||||
}
|
||||
|
||||
@@ -127,8 +127,6 @@ func (t *ScanTask) scanScene() {
|
||||
Checksum: checksum,
|
||||
Path: t.FilePath,
|
||||
Title: sql.NullString{String: videoFile.Title, Valid: true},
|
||||
Details: sql.NullString{String: videoFile.Comment, Valid: true},
|
||||
Date: models.SQLiteDate{String: videoFile.CreationTime.Format("2006-01-02")},
|
||||
Duration: sql.NullFloat64{Float64: videoFile.Duration, Valid: true},
|
||||
VideoCodec: sql.NullString{String: videoFile.VideoCodec, Valid: true},
|
||||
AudioCodec: sql.NullString{String: videoFile.AudioCodec, Valid: true},
|
||||
@@ -140,6 +138,11 @@ func (t *ScanTask) scanScene() {
|
||||
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||
}
|
||||
|
||||
if t.UseFileMetadata {
|
||||
newScene.Details = sql.NullString{String: videoFile.Comment, Valid: true}
|
||||
newScene.Date = models.SQLiteDate{String: videoFile.CreationTime.Format("2006-01-02")}
|
||||
}
|
||||
_, err = qb.Create(newScene, tx)
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,13 @@ func (g *Gallery) GetImage(index int) []byte {
|
||||
return data
|
||||
}
|
||||
|
||||
func (g *Gallery) GetThumbnail(index int) []byte {
|
||||
func (g *Gallery) GetThumbnail(index int, width int) []byte {
|
||||
data, _ := g.readZipFile(index)
|
||||
srcImage, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
resizedImage := imaging.Resize(srcImage, 100, 0, imaging.NearestNeighbor)
|
||||
resizedImage := imaging.Resize(srcImage, width, 0, imaging.Box)
|
||||
buf := new(bytes.Buffer)
|
||||
err = jpeg.Encode(buf, resizedImage, nil)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,17 +2,20 @@ package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type Scene struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Checksum string `db:"checksum" json:"checksum"`
|
||||
Path string `db:"path" json:"path"`
|
||||
Cover []byte `db:"cover" json:"cover"`
|
||||
Title sql.NullString `db:"title" json:"title"`
|
||||
Details sql.NullString `db:"details" json:"details"`
|
||||
URL sql.NullString `db:"url" json:"url"`
|
||||
Date SQLiteDate `db:"date" json:"date"`
|
||||
Rating sql.NullInt64 `db:"rating" json:"rating"`
|
||||
OCounter int `db:"o_counter" json:"o_counter"`
|
||||
Size sql.NullString `db:"size" json:"size"`
|
||||
Duration sql.NullFloat64 `db:"duration" json:"duration"`
|
||||
VideoCodec sql.NullString `db:"video_codec" json:"video_codec"`
|
||||
@@ -27,9 +30,10 @@ type Scene struct {
|
||||
}
|
||||
|
||||
type ScenePartial struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
ID int `db:"id" json:"id"`
|
||||
Checksum *string `db:"checksum" json:"checksum"`
|
||||
Path *string `db:"path" json:"path"`
|
||||
Cover *[]byte `db:"cover" json:"cover"`
|
||||
Title *sql.NullString `db:"title" json:"title"`
|
||||
Details *sql.NullString `db:"details" json:"details"`
|
||||
URL *sql.NullString `db:"url" json:"url"`
|
||||
@@ -47,3 +51,22 @@ type ScenePartial struct {
|
||||
CreatedAt *SQLiteTimestamp `db:"created_at" json:"created_at"`
|
||||
UpdatedAt *SQLiteTimestamp `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (s Scene) GetTitle() string {
|
||||
if s.Title.String != "" {
|
||||
return s.Title.String
|
||||
}
|
||||
|
||||
return filepath.Base(s.Path)
|
||||
}
|
||||
|
||||
type SceneFileType struct {
|
||||
Size *string `graphql:"size" json:"size"`
|
||||
Duration *float64 `graphql:"duration" json:"duration"`
|
||||
VideoCodec *string `graphql:"video_codec" json:"video_codec"`
|
||||
AudioCodec *string `graphql:"audio_codec" json:"audio_codec"`
|
||||
Width *int `graphql:"width" json:"width"`
|
||||
Height *int `graphql:"height" json:"height"`
|
||||
Framerate *float64 `graphql:"framerate" json:"framerate"`
|
||||
Bitrate *int `graphql:"bitrate" json:"bitrate"`
|
||||
}
|
||||
|
||||
@@ -22,3 +22,65 @@ type ScrapedItem struct {
|
||||
CreatedAt SQLiteTimestamp `db:"created_at" json:"created_at"`
|
||||
UpdatedAt SQLiteTimestamp `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
type ScrapedPerformer struct {
|
||||
Name *string `graphql:"name" json:"name"`
|
||||
URL *string `graphql:"url" json:"url"`
|
||||
Twitter *string `graphql:"twitter" json:"twitter"`
|
||||
Instagram *string `graphql:"instagram" json:"instagram"`
|
||||
Birthdate *string `graphql:"birthdate" json:"birthdate"`
|
||||
Ethnicity *string `graphql:"ethnicity" json:"ethnicity"`
|
||||
Country *string `graphql:"country" json:"country"`
|
||||
EyeColor *string `graphql:"eye_color" json:"eye_color"`
|
||||
Height *string `graphql:"height" json:"height"`
|
||||
Measurements *string `graphql:"measurements" json:"measurements"`
|
||||
FakeTits *string `graphql:"fake_tits" json:"fake_tits"`
|
||||
CareerLength *string `graphql:"career_length" json:"career_length"`
|
||||
Tattoos *string `graphql:"tattoos" json:"tattoos"`
|
||||
Piercings *string `graphql:"piercings" json:"piercings"`
|
||||
Aliases *string `graphql:"aliases" json:"aliases"`
|
||||
}
|
||||
|
||||
type ScrapedScene struct {
|
||||
Title *string `graphql:"title" json:"title"`
|
||||
Details *string `graphql:"details" json:"details"`
|
||||
URL *string `graphql:"url" json:"url"`
|
||||
Date *string `graphql:"date" json:"date"`
|
||||
File *SceneFileType `graphql:"file" json:"file"`
|
||||
Studio *ScrapedSceneStudio `graphql:"studio" json:"studio"`
|
||||
Tags []*ScrapedSceneTag `graphql:"tags" json:"tags"`
|
||||
Performers []*ScrapedScenePerformer `graphql:"performers" json:"performers"`
|
||||
}
|
||||
|
||||
type ScrapedScenePerformer struct {
|
||||
// Set if performer matched
|
||||
ID *string `graphql:"id" json:"id"`
|
||||
Name string `graphql:"name" json:"name"`
|
||||
URL *string `graphql:"url" json:"url"`
|
||||
Twitter *string `graphql:"twitter" json:"twitter"`
|
||||
Instagram *string `graphql:"instagram" json:"instagram"`
|
||||
Birthdate *string `graphql:"birthdate" json:"birthdate"`
|
||||
Ethnicity *string `graphql:"ethnicity" json:"ethnicity"`
|
||||
Country *string `graphql:"country" json:"country"`
|
||||
EyeColor *string `graphql:"eye_color" json:"eye_color"`
|
||||
Height *string `graphql:"height" json:"height"`
|
||||
Measurements *string `graphql:"measurements" json:"measurements"`
|
||||
FakeTits *string `graphql:"fake_tits" json:"fake_tits"`
|
||||
CareerLength *string `graphql:"career_length" json:"career_length"`
|
||||
Tattoos *string `graphql:"tattoos" json:"tattoos"`
|
||||
Piercings *string `graphql:"piercings" json:"piercings"`
|
||||
Aliases *string `graphql:"aliases" json:"aliases"`
|
||||
}
|
||||
|
||||
type ScrapedSceneStudio struct {
|
||||
// Set if studio matched
|
||||
ID *string `graphql:"id" json:"id"`
|
||||
Name string `graphql:"name" json:"name"`
|
||||
URL *string `graphql:"url" json:"url"`
|
||||
}
|
||||
|
||||
type ScrapedSceneTag struct {
|
||||
// Set if tag matched
|
||||
ID *string `graphql:"id" json:"id"`
|
||||
Name string `graphql:"name" json:"name"`
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package models
|
||||
|
||||
import "github.com/jmoiron/sqlx"
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/stashapp/stash/pkg/database"
|
||||
)
|
||||
|
||||
type JoinsQueryBuilder struct{}
|
||||
|
||||
@@ -8,6 +13,41 @@ func NewJoinsQueryBuilder() JoinsQueryBuilder {
|
||||
return JoinsQueryBuilder{}
|
||||
}
|
||||
|
||||
func (qb *JoinsQueryBuilder) GetScenePerformers(sceneID int, tx *sqlx.Tx) ([]PerformersScenes, error) {
|
||||
ensureTx(tx)
|
||||
|
||||
// Delete the existing joins and then create new ones
|
||||
query := `SELECT * from performers_scenes WHERE scene_id = ?`
|
||||
|
||||
var rows *sqlx.Rows
|
||||
var err error
|
||||
if tx != nil {
|
||||
rows, err = tx.Queryx(query, sceneID)
|
||||
} else {
|
||||
rows, err = database.DB.Queryx(query, sceneID)
|
||||
}
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
performerScenes := make([]PerformersScenes, 0)
|
||||
for rows.Next() {
|
||||
performerScene := PerformersScenes{}
|
||||
if err := rows.StructScan(&performerScene); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
performerScenes = append(performerScenes, performerScene)
|
||||
}
|
||||
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return performerScenes, nil
|
||||
}
|
||||
|
||||
func (qb *JoinsQueryBuilder) CreatePerformersScenes(newJoins []PerformersScenes, tx *sqlx.Tx) error {
|
||||
ensureTx(tx)
|
||||
for _, join := range newJoins {
|
||||
@@ -22,6 +62,36 @@ func (qb *JoinsQueryBuilder) CreatePerformersScenes(newJoins []PerformersScenes,
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddPerformerScene adds a performer to a scene. It does not make any change
|
||||
// if the performer already exists on the scene. It returns true if scene
|
||||
// performer was added.
|
||||
func (qb *JoinsQueryBuilder) AddPerformerScene(sceneID int, performerID int, tx *sqlx.Tx) (bool, error) {
|
||||
ensureTx(tx)
|
||||
|
||||
existingPerformers, err := qb.GetScenePerformers(sceneID, tx)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// ensure not already present
|
||||
for _, p := range existingPerformers {
|
||||
if p.PerformerID == performerID && p.SceneID == sceneID {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
performerJoin := PerformersScenes{
|
||||
PerformerID: performerID,
|
||||
SceneID: sceneID,
|
||||
}
|
||||
performerJoins := append(existingPerformers, performerJoin)
|
||||
|
||||
err = qb.UpdatePerformersScenes(sceneID, performerJoins, tx)
|
||||
|
||||
return err == nil, err
|
||||
}
|
||||
|
||||
func (qb *JoinsQueryBuilder) UpdatePerformersScenes(sceneID int, updatedJoins []PerformersScenes, tx *sqlx.Tx) error {
|
||||
ensureTx(tx)
|
||||
|
||||
@@ -41,6 +111,41 @@ func (qb *JoinsQueryBuilder) DestroyPerformersScenes(sceneID int, tx *sqlx.Tx) e
|
||||
return err
|
||||
}
|
||||
|
||||
func (qb *JoinsQueryBuilder) GetSceneTags(sceneID int, tx *sqlx.Tx) ([]ScenesTags, error) {
|
||||
ensureTx(tx)
|
||||
|
||||
// Delete the existing joins and then create new ones
|
||||
query := `SELECT * from scenes_tags WHERE scene_id = ?`
|
||||
|
||||
var rows *sqlx.Rows
|
||||
var err error
|
||||
if tx != nil {
|
||||
rows, err = tx.Queryx(query, sceneID)
|
||||
} else {
|
||||
rows, err = database.DB.Queryx(query, sceneID)
|
||||
}
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
sceneTags := make([]ScenesTags, 0)
|
||||
for rows.Next() {
|
||||
sceneTag := ScenesTags{}
|
||||
if err := rows.StructScan(&sceneTag); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sceneTags = append(sceneTags, sceneTag)
|
||||
}
|
||||
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sceneTags, nil
|
||||
}
|
||||
|
||||
func (qb *JoinsQueryBuilder) CreateScenesTags(newJoins []ScenesTags, tx *sqlx.Tx) error {
|
||||
ensureTx(tx)
|
||||
for _, join := range newJoins {
|
||||
@@ -66,6 +171,35 @@ func (qb *JoinsQueryBuilder) UpdateScenesTags(sceneID int, updatedJoins []Scenes
|
||||
return qb.CreateScenesTags(updatedJoins, tx)
|
||||
}
|
||||
|
||||
// AddSceneTag adds a tag to a scene. It does not make any change if the tag
|
||||
// already exists on the scene. It returns true if scene tag was added.
|
||||
func (qb *JoinsQueryBuilder) AddSceneTag(sceneID int, tagID int, tx *sqlx.Tx) (bool, error) {
|
||||
ensureTx(tx)
|
||||
|
||||
existingTags, err := qb.GetSceneTags(sceneID, tx)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// ensure not already present
|
||||
for _, p := range existingTags {
|
||||
if p.TagID == tagID && p.SceneID == sceneID {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
tagJoin := ScenesTags{
|
||||
TagID: tagID,
|
||||
SceneID: sceneID,
|
||||
}
|
||||
tagJoins := append(existingTags, tagJoin)
|
||||
|
||||
err = qb.UpdateScenesTags(sceneID, tagJoins, tx)
|
||||
|
||||
return err == nil, err
|
||||
}
|
||||
|
||||
func (qb *JoinsQueryBuilder) DestroyScenesTags(sceneID int, tx *sqlx.Tx) error {
|
||||
ensureTx(tx)
|
||||
|
||||
|
||||
@@ -42,9 +42,11 @@ func (qb *SceneQueryBuilder) Create(newScene Scene, tx *sqlx.Tx) (*Scene, error)
|
||||
ensureTx(tx)
|
||||
result, err := tx.NamedExec(
|
||||
`INSERT INTO scenes (checksum, path, title, details, url, date, rating, size, duration, video_codec,
|
||||
audio_codec, width, height, framerate, bitrate, studio_id, created_at, updated_at)
|
||||
audio_codec, width, height, framerate, bitrate, studio_id, cover,
|
||||
created_at, updated_at)
|
||||
VALUES (:checksum, :path, :title, :details, :url, :date, :rating, :size, :duration, :video_codec,
|
||||
:audio_codec, :width, :height, :framerate, :bitrate, :studio_id, :created_at, :updated_at)
|
||||
:audio_codec, :width, :height, :framerate, :bitrate, :studio_id, :cover,
|
||||
:created_at, :updated_at)
|
||||
`,
|
||||
newScene,
|
||||
)
|
||||
@@ -74,6 +76,60 @@ func (qb *SceneQueryBuilder) Update(updatedScene ScenePartial, tx *sqlx.Tx) (*Sc
|
||||
return qb.find(updatedScene.ID, tx)
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) IncrementOCounter(id int, tx *sqlx.Tx) (int, error) {
|
||||
ensureTx(tx)
|
||||
_, err := tx.Exec(
|
||||
`UPDATE scenes SET o_counter = o_counter + 1 WHERE scenes.id = ?`,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
scene, err := qb.find(id, tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return scene.OCounter, nil
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) DecrementOCounter(id int, tx *sqlx.Tx) (int, error) {
|
||||
ensureTx(tx)
|
||||
_, err := tx.Exec(
|
||||
`UPDATE scenes SET o_counter = o_counter - 1 WHERE scenes.id = ? and scenes.o_counter > 0`,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
scene, err := qb.find(id, tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return scene.OCounter, nil
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) ResetOCounter(id int, tx *sqlx.Tx) (int, error) {
|
||||
ensureTx(tx)
|
||||
_, err := tx.Exec(
|
||||
`UPDATE scenes SET o_counter = 0 WHERE scenes.id = ?`,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
scene, err := qb.find(id, tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return scene.OCounter, nil
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) Destroy(id string, tx *sqlx.Tx) error {
|
||||
return executeDeleteQuery("scenes", id, tx)
|
||||
}
|
||||
@@ -169,13 +225,27 @@ func (qb *SceneQueryBuilder) Query(sceneFilter *SceneFilterType, findFilter *Fin
|
||||
}
|
||||
|
||||
if rating := sceneFilter.Rating; rating != nil {
|
||||
clause, count := getIntCriterionWhereClause("rating", *sceneFilter.Rating)
|
||||
clause, count := getIntCriterionWhereClause("scenes.rating", *sceneFilter.Rating)
|
||||
whereClauses = append(whereClauses, clause)
|
||||
if count == 1 {
|
||||
args = append(args, sceneFilter.Rating.Value)
|
||||
}
|
||||
}
|
||||
|
||||
if oCounter := sceneFilter.OCounter; oCounter != nil {
|
||||
clause, count := getIntCriterionWhereClause("scenes.o_counter", *sceneFilter.OCounter)
|
||||
whereClauses = append(whereClauses, clause)
|
||||
if count == 1 {
|
||||
args = append(args, sceneFilter.OCounter.Value)
|
||||
}
|
||||
}
|
||||
|
||||
if durationFilter := sceneFilter.Duration; durationFilter != nil {
|
||||
clause, thisArgs := getDurationWhereClause(*durationFilter)
|
||||
whereClauses = append(whereClauses, clause)
|
||||
args = append(args, thisArgs...)
|
||||
}
|
||||
|
||||
if resolutionFilter := sceneFilter.Resolution; resolutionFilter != nil {
|
||||
if resolution := resolutionFilter.String(); resolutionFilter.IsValid() {
|
||||
switch resolution {
|
||||
@@ -268,6 +338,34 @@ func appendClause(clauses []string, clause string) []string {
|
||||
return clauses
|
||||
}
|
||||
|
||||
func getDurationWhereClause(durationFilter IntCriterionInput) (string, []interface{}) {
|
||||
// special case for duration. We accept duration as seconds as int but the
|
||||
// field is floating point. Change the equals filter to return a range
|
||||
// between x and x + 1
|
||||
// likewise, not equals needs to be duration < x OR duration >= x
|
||||
var clause string
|
||||
args := []interface{}{}
|
||||
|
||||
value := durationFilter.Value
|
||||
if durationFilter.Modifier == CriterionModifierEquals {
|
||||
clause = "scenes.duration >= ? AND scenes.duration < ?"
|
||||
args = append(args, value)
|
||||
args = append(args, value+1)
|
||||
} else if durationFilter.Modifier == CriterionModifierNotEquals {
|
||||
clause = "(scenes.duration < ? OR scenes.duration >= ?)"
|
||||
args = append(args, value)
|
||||
args = append(args, value+1)
|
||||
} else {
|
||||
var count int
|
||||
clause, count = getIntCriterionWhereClause("scenes.duration", durationFilter)
|
||||
if count == 1 {
|
||||
args = append(args, value)
|
||||
}
|
||||
}
|
||||
|
||||
return clause, args
|
||||
}
|
||||
|
||||
// returns where clause and having clause
|
||||
func getMultiCriterionClause(table string, joinTable string, joinTableField string, criterion *MultiCriterionInput) (string, string) {
|
||||
whereClause := ""
|
||||
@@ -291,6 +389,32 @@ func getMultiCriterionClause(table string, joinTable string, joinTableField stri
|
||||
return whereClause, havingClause
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) QueryAllByPathRegex(regex string) ([]*Scene, error) {
|
||||
var args []interface{}
|
||||
body := selectDistinctIDs("scenes") + " WHERE scenes.path regexp ?"
|
||||
|
||||
args = append(args, "(?i)"+regex)
|
||||
|
||||
idsResult, err := runIdsQuery(body, args)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var scenes []*Scene
|
||||
for _, id := range idsResult {
|
||||
scene, err := qb.Find(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
scenes = append(scenes, scene)
|
||||
}
|
||||
|
||||
return scenes, nil
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) QueryByPathRegex(findFilter *FindFilterType) ([]*Scene, int) {
|
||||
if findFilter == nil {
|
||||
findFilter = &FindFilterType{}
|
||||
@@ -302,7 +426,8 @@ func (qb *SceneQueryBuilder) QueryByPathRegex(findFilter *FindFilterType) ([]*Sc
|
||||
body := selectDistinctIDs("scenes")
|
||||
|
||||
if q := findFilter.Q; q != nil && *q != "" {
|
||||
whereClauses = append(whereClauses, "scenes.path regexp '(?i)"+*q+"'")
|
||||
whereClauses = append(whereClauses, "scenes.path regexp ?")
|
||||
args = append(args, "(?i)"+*q)
|
||||
}
|
||||
|
||||
sortAndPagination := qb.getSceneSort(findFilter) + getPagination(findFilter)
|
||||
|
||||
@@ -162,8 +162,8 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
|
||||
havingClauses = append(havingClauses, "((COUNT(DISTINCT ptj.id) + COUNT(DISTINCT tj.tag_id)) >= "+strconv.Itoa(requiredCount)+")")
|
||||
} else if tagsFilter.Modifier == CriterionModifierExcludes {
|
||||
// excludes all of the provided ids
|
||||
whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in " + getInBinding(length))
|
||||
whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in " + getInBinding(length) + ")")
|
||||
whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in "+getInBinding(length))
|
||||
whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in "+getInBinding(length)+")")
|
||||
}
|
||||
|
||||
for _, tagID := range tagsFilter.Value {
|
||||
@@ -191,7 +191,7 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
|
||||
havingClauses = append(havingClauses, "COUNT(DISTINCT scene_tags_join.tag_id) >= "+strconv.Itoa(requiredCount))
|
||||
} else if sceneTagsFilter.Modifier == CriterionModifierExcludes {
|
||||
// excludes all of the provided ids
|
||||
whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN " + getInBinding(length) + ")")
|
||||
whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN "+getInBinding(length)+")")
|
||||
}
|
||||
|
||||
for _, tagID := range sceneTagsFilter.Value {
|
||||
@@ -217,7 +217,7 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
|
||||
havingClauses = append(havingClauses, "COUNT(DISTINCT scene_performers.performer_id) >= "+strconv.Itoa(requiredCount))
|
||||
} else if performersFilter.Modifier == CriterionModifierExcludes {
|
||||
// excludes all of the provided ids
|
||||
whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN " + getInBinding(length) + ")")
|
||||
whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN "+getInBinding(length)+")")
|
||||
}
|
||||
|
||||
for _, performerID := range performersFilter.Value {
|
||||
|
||||
@@ -93,19 +93,27 @@ func getSort(sort string, direction string, tableName string) string {
|
||||
direction = "ASC"
|
||||
}
|
||||
|
||||
if strings.Contains(sort, "_count") {
|
||||
const randomSeedPrefix = "random_"
|
||||
|
||||
if strings.HasSuffix(sort, "_count") {
|
||||
var relationTableName = strings.Split(sort, "_")[0] // TODO: pluralize?
|
||||
colName := getColumn(relationTableName, "id")
|
||||
return " ORDER BY COUNT(distinct " + colName + ") " + direction
|
||||
} else if strings.Compare(sort, "filesize") == 0 {
|
||||
colName := getColumn(tableName, "size")
|
||||
return " ORDER BY cast(" + colName + " as integer) " + direction
|
||||
} else if strings.HasPrefix(sort, randomSeedPrefix) {
|
||||
// seed as a parameter from the UI
|
||||
// turn the provided seed into a float
|
||||
seedStr := "0." + sort[len(randomSeedPrefix):]
|
||||
seed, err := strconv.ParseFloat(seedStr, 32)
|
||||
if err != nil {
|
||||
// fallback to default seed
|
||||
seed = randomSortFloat
|
||||
}
|
||||
return getRandomSort(tableName, direction, seed)
|
||||
} else if strings.Compare(sort, "random") == 0 {
|
||||
// https://stackoverflow.com/a/24511461
|
||||
// TODO seed as a parameter from the UI
|
||||
colName := getColumn(tableName, "id")
|
||||
randomSortString := strconv.FormatFloat(randomSortFloat, 'f', 16, 32)
|
||||
return " ORDER BY " + "(substr(" + colName + " * " + randomSortString + ", length(" + colName + ") + 2))" + " " + direction
|
||||
return getRandomSort(tableName, direction, randomSortFloat)
|
||||
} else {
|
||||
colName := getColumn(tableName, sort)
|
||||
var additional string
|
||||
@@ -122,6 +130,13 @@ func getSort(sort string, direction string, tableName string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func getRandomSort(tableName string, direction string, seed float64) string {
|
||||
// https://stackoverflow.com/a/24511461
|
||||
colName := getColumn(tableName, "id")
|
||||
randomSortString := strconv.FormatFloat(seed, 'f', 16, 32)
|
||||
return " ORDER BY " + "(substr(" + colName + " * " + randomSortString + ", length(" + colName + ") + 2))" + " " + direction
|
||||
}
|
||||
|
||||
func getSearch(columns []string, q string) string {
|
||||
// TODO - susceptible to SQL injection
|
||||
var likeClauses []string
|
||||
|
||||
336
pkg/scraper/config.go
Normal file
336
pkg/scraper/config.go
Normal file
@@ -0,0 +1,336 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
type stashServer struct {
|
||||
URL string `yaml:"url"`
|
||||
}
|
||||
|
||||
type scraperAction string
|
||||
|
||||
const (
|
||||
scraperActionScript scraperAction = "script"
|
||||
scraperActionStash scraperAction = "stash"
|
||||
scraperActionXPath scraperAction = "scrapeXPath"
|
||||
)
|
||||
|
||||
var allScraperAction = []scraperAction{
|
||||
scraperActionScript,
|
||||
scraperActionStash,
|
||||
scraperActionXPath,
|
||||
}
|
||||
|
||||
func (e scraperAction) IsValid() bool {
|
||||
switch e {
|
||||
case scraperActionScript, scraperActionStash, scraperActionXPath:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type scraperTypeConfig struct {
|
||||
Action scraperAction `yaml:"action"`
|
||||
Script []string `yaml:"script,flow"`
|
||||
Scraper string `yaml:"scraper"`
|
||||
|
||||
// for xpath name scraper only
|
||||
QueryURL string `yaml:"queryURL"`
|
||||
|
||||
scraperConfig *scraperConfig
|
||||
}
|
||||
|
||||
type scrapePerformerNamesFunc func(c scraperTypeConfig, name string) ([]*models.ScrapedPerformer, error)
|
||||
|
||||
type performerByNameConfig struct {
|
||||
scraperTypeConfig `yaml:",inline"`
|
||||
performScrape scrapePerformerNamesFunc
|
||||
}
|
||||
|
||||
func (c *performerByNameConfig) resolveFn() {
|
||||
if c.Action == scraperActionScript {
|
||||
c.performScrape = scrapePerformerNamesScript
|
||||
} else if c.Action == scraperActionStash {
|
||||
c.performScrape = scrapePerformerNamesStash
|
||||
} else if c.Action == scraperActionXPath {
|
||||
c.performScrape = scrapePerformerNamesXPath
|
||||
}
|
||||
}
|
||||
|
||||
type scrapePerformerFragmentFunc func(c scraperTypeConfig, scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error)
|
||||
|
||||
type performerByFragmentConfig struct {
|
||||
scraperTypeConfig `yaml:",inline"`
|
||||
performScrape scrapePerformerFragmentFunc
|
||||
}
|
||||
|
||||
func (c *performerByFragmentConfig) resolveFn() {
|
||||
if c.Action == scraperActionScript {
|
||||
c.performScrape = scrapePerformerFragmentScript
|
||||
} else if c.Action == scraperActionStash {
|
||||
c.performScrape = scrapePerformerFragmentStash
|
||||
}
|
||||
}
|
||||
|
||||
type scrapeByURLConfig struct {
|
||||
scraperTypeConfig `yaml:",inline"`
|
||||
URL []string `yaml:"url,flow"`
|
||||
}
|
||||
|
||||
func (c scrapeByURLConfig) matchesURL(url string) bool {
|
||||
for _, thisURL := range c.URL {
|
||||
if strings.Contains(url, thisURL) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
type scrapePerformerByURLFunc func(c scraperTypeConfig, url string) (*models.ScrapedPerformer, error)
|
||||
|
||||
type scrapePerformerByURLConfig struct {
|
||||
scrapeByURLConfig `yaml:",inline"`
|
||||
performScrape scrapePerformerByURLFunc
|
||||
}
|
||||
|
||||
func (c *scrapePerformerByURLConfig) resolveFn() {
|
||||
if c.Action == scraperActionScript {
|
||||
c.performScrape = scrapePerformerURLScript
|
||||
} else if c.Action == scraperActionXPath {
|
||||
c.performScrape = scrapePerformerURLXpath
|
||||
}
|
||||
}
|
||||
|
||||
type scrapeSceneFragmentFunc func(c scraperTypeConfig, scene models.SceneUpdateInput) (*models.ScrapedScene, error)
|
||||
|
||||
type sceneByFragmentConfig struct {
|
||||
scraperTypeConfig `yaml:",inline"`
|
||||
performScrape scrapeSceneFragmentFunc
|
||||
}
|
||||
|
||||
func (c *sceneByFragmentConfig) resolveFn() {
|
||||
if c.Action == scraperActionScript {
|
||||
c.performScrape = scrapeSceneFragmentScript
|
||||
} else if c.Action == scraperActionStash {
|
||||
c.performScrape = scrapeSceneFragmentStash
|
||||
}
|
||||
}
|
||||
|
||||
type scrapeSceneByURLFunc func(c scraperTypeConfig, url string) (*models.ScrapedScene, error)
|
||||
|
||||
type scrapeSceneByURLConfig struct {
|
||||
scrapeByURLConfig `yaml:",inline"`
|
||||
performScrape scrapeSceneByURLFunc
|
||||
}
|
||||
|
||||
func (c *scrapeSceneByURLConfig) resolveFn() {
|
||||
if c.Action == scraperActionScript {
|
||||
c.performScrape = scrapeSceneURLScript
|
||||
} else if c.Action == scraperActionXPath {
|
||||
c.performScrape = scrapeSceneURLXPath
|
||||
}
|
||||
}
|
||||
|
||||
type scraperConfig struct {
|
||||
ID string
|
||||
Name string `yaml:"name"`
|
||||
PerformerByName *performerByNameConfig `yaml:"performerByName"`
|
||||
PerformerByFragment *performerByFragmentConfig `yaml:"performerByFragment"`
|
||||
PerformerByURL []*scrapePerformerByURLConfig `yaml:"performerByURL"`
|
||||
SceneByFragment *sceneByFragmentConfig `yaml:"sceneByFragment"`
|
||||
SceneByURL []*scrapeSceneByURLConfig `yaml:"sceneByURL"`
|
||||
|
||||
StashServer *stashServer `yaml:"stashServer"`
|
||||
XPathScrapers xpathScrapers `yaml:"xPathScrapers"`
|
||||
}
|
||||
|
||||
func loadScraperFromYAML(path string) (*scraperConfig, error) {
|
||||
ret := &scraperConfig{}
|
||||
|
||||
file, err := os.Open(path)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
parser := yaml.NewDecoder(file)
|
||||
parser.SetStrict(true)
|
||||
err = parser.Decode(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// set id to the filename
|
||||
id := filepath.Base(path)
|
||||
id = id[:strings.LastIndex(id, ".")]
|
||||
ret.ID = id
|
||||
|
||||
// set the scraper interface
|
||||
ret.initialiseConfigs()
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (c *scraperConfig) initialiseConfigs() {
|
||||
if c.PerformerByName != nil {
|
||||
c.PerformerByName.resolveFn()
|
||||
c.PerformerByName.scraperConfig = c
|
||||
}
|
||||
if c.PerformerByFragment != nil {
|
||||
c.PerformerByFragment.resolveFn()
|
||||
c.PerformerByFragment.scraperConfig = c
|
||||
}
|
||||
for _, s := range c.PerformerByURL {
|
||||
s.resolveFn()
|
||||
s.scraperConfig = c
|
||||
}
|
||||
|
||||
if c.SceneByFragment != nil {
|
||||
c.SceneByFragment.resolveFn()
|
||||
c.SceneByFragment.scraperConfig = c
|
||||
}
|
||||
for _, s := range c.SceneByURL {
|
||||
s.resolveFn()
|
||||
s.scraperConfig = c
|
||||
}
|
||||
}
|
||||
|
||||
func (c scraperConfig) toScraper() *models.Scraper {
|
||||
ret := models.Scraper{
|
||||
ID: c.ID,
|
||||
Name: c.Name,
|
||||
}
|
||||
|
||||
performer := models.ScraperSpec{}
|
||||
if c.PerformerByName != nil {
|
||||
performer.SupportedScrapes = append(performer.SupportedScrapes, models.ScrapeTypeName)
|
||||
}
|
||||
if c.PerformerByFragment != nil {
|
||||
performer.SupportedScrapes = append(performer.SupportedScrapes, models.ScrapeTypeFragment)
|
||||
}
|
||||
if len(c.PerformerByURL) > 0 {
|
||||
performer.SupportedScrapes = append(performer.SupportedScrapes, models.ScrapeTypeURL)
|
||||
for _, v := range c.PerformerByURL {
|
||||
performer.Urls = append(performer.Urls, v.URL...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(performer.SupportedScrapes) > 0 {
|
||||
ret.Performer = &performer
|
||||
}
|
||||
|
||||
scene := models.ScraperSpec{}
|
||||
if c.SceneByFragment != nil {
|
||||
scene.SupportedScrapes = append(scene.SupportedScrapes, models.ScrapeTypeFragment)
|
||||
}
|
||||
if len(c.SceneByURL) > 0 {
|
||||
scene.SupportedScrapes = append(scene.SupportedScrapes, models.ScrapeTypeURL)
|
||||
for _, v := range c.SceneByURL {
|
||||
scene.Urls = append(scene.Urls, v.URL...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(scene.SupportedScrapes) > 0 {
|
||||
ret.Scene = &scene
|
||||
}
|
||||
|
||||
return &ret
|
||||
}
|
||||
|
||||
func (c scraperConfig) supportsPerformers() bool {
|
||||
return c.PerformerByName != nil || c.PerformerByFragment != nil || len(c.PerformerByURL) > 0
|
||||
}
|
||||
|
||||
func (c scraperConfig) matchesPerformerURL(url string) bool {
|
||||
for _, scraper := range c.PerformerByURL {
|
||||
if scraper.matchesURL(url) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (c scraperConfig) ScrapePerformerNames(name string) ([]*models.ScrapedPerformer, error) {
|
||||
if c.PerformerByName != nil && c.PerformerByName.performScrape != nil {
|
||||
return c.PerformerByName.performScrape(c.PerformerByName.scraperTypeConfig, name)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c scraperConfig) ScrapePerformer(scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error) {
|
||||
if c.PerformerByFragment != nil && c.PerformerByFragment.performScrape != nil {
|
||||
return c.PerformerByFragment.performScrape(c.PerformerByFragment.scraperTypeConfig, scrapedPerformer)
|
||||
}
|
||||
|
||||
// try to match against URL if present
|
||||
if scrapedPerformer.URL != nil && *scrapedPerformer.URL != "" {
|
||||
return c.ScrapePerformerURL(*scrapedPerformer.URL)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c scraperConfig) ScrapePerformerURL(url string) (*models.ScrapedPerformer, error) {
|
||||
for _, scraper := range c.PerformerByURL {
|
||||
if scraper.matchesURL(url) && scraper.performScrape != nil {
|
||||
ret, err := scraper.performScrape(scraper.scraperTypeConfig, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if ret != nil {
|
||||
return ret, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c scraperConfig) supportsScenes() bool {
|
||||
return c.SceneByFragment != nil || len(c.SceneByURL) > 0
|
||||
}
|
||||
|
||||
func (c scraperConfig) matchesSceneURL(url string) bool {
|
||||
for _, scraper := range c.SceneByURL {
|
||||
if scraper.matchesURL(url) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (c scraperConfig) ScrapeScene(scene models.SceneUpdateInput) (*models.ScrapedScene, error) {
|
||||
if c.SceneByFragment != nil && c.SceneByFragment.performScrape != nil {
|
||||
return c.SceneByFragment.performScrape(c.SceneByFragment.scraperTypeConfig, scene)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c scraperConfig) ScrapeSceneURL(url string) (*models.ScrapedScene, error) {
|
||||
for _, scraper := range c.SceneByURL {
|
||||
if scraper.matchesURL(url) && scraper.performScrape != nil {
|
||||
ret, err := scraper.performScrape(scraper.scraperTypeConfig, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if ret != nil {
|
||||
return ret, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
@@ -2,17 +2,46 @@ package scraper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
func GetPerformerNames(q string) ([]string, error) {
|
||||
const freeonesScraperID = "builtin_freeones"
|
||||
const freeonesName = "Freeones"
|
||||
|
||||
var freeonesURLs = []string{
|
||||
"freeones.com",
|
||||
}
|
||||
|
||||
func GetFreeonesScraper() scraperConfig {
|
||||
return scraperConfig{
|
||||
ID: freeonesScraperID,
|
||||
Name: "Freeones",
|
||||
PerformerByName: &performerByNameConfig{
|
||||
performScrape: GetPerformerNames,
|
||||
},
|
||||
PerformerByFragment: &performerByFragmentConfig{
|
||||
performScrape: GetPerformer,
|
||||
},
|
||||
PerformerByURL: []*scrapePerformerByURLConfig{
|
||||
&scrapePerformerByURLConfig{
|
||||
scrapeByURLConfig: scrapeByURLConfig{
|
||||
URL: freeonesURLs,
|
||||
},
|
||||
performScrape: GetPerformerURL,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func GetPerformerNames(c scraperTypeConfig, q string) ([]*models.ScrapedPerformer, error) {
|
||||
// Request the HTML page.
|
||||
queryURL := "https://www.freeones.com/suggestions.php?q=" + url.PathEscape(q) + "&t=1"
|
||||
res, err := http.Get(queryURL)
|
||||
@@ -31,65 +60,42 @@ func GetPerformerNames(q string) ([]string, error) {
|
||||
}
|
||||
|
||||
// Find the performers
|
||||
var performerNames []string
|
||||
var performers []*models.ScrapedPerformer
|
||||
doc.Find(".suggestion").Each(func(i int, s *goquery.Selection) {
|
||||
name := strings.Trim(s.Text(), " ")
|
||||
performerNames = append(performerNames, name)
|
||||
p := models.ScrapedPerformer{
|
||||
Name: &name,
|
||||
}
|
||||
performers = append(performers, &p)
|
||||
})
|
||||
|
||||
return performerNames, nil
|
||||
return performers, nil
|
||||
}
|
||||
|
||||
func GetPerformer(performerName string) (*models.ScrapedPerformer, error) {
|
||||
queryURL := "https://www.freeones.com/search/?t=1&q=" + url.PathEscape(performerName) + "&view=thumbs"
|
||||
res, err := http.Get(queryURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("status code error: %d %s", res.StatusCode, res.Status)
|
||||
func GetPerformerURL(c scraperTypeConfig, href string) (*models.ScrapedPerformer, error) {
|
||||
// if we're already in the bio page, just scrape it
|
||||
if regexp.MustCompile(`\/bio_.*\.php$`).MatchString(href) {
|
||||
return getPerformerBio(c, href)
|
||||
}
|
||||
|
||||
// Load the HTML document
|
||||
doc, err := goquery.NewDocumentFromReader(res.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// otherwise try to get the bio page from the url
|
||||
profileRE := regexp.MustCompile(`_links\/(.*?)\/$`)
|
||||
if profileRE.MatchString(href) {
|
||||
href = profileRE.ReplaceAllString(href, "_links/bio_$1.php")
|
||||
return getPerformerBio(c, href)
|
||||
}
|
||||
|
||||
performerLink := doc.Find("div.Block3 a").FilterFunction(func(i int, s *goquery.Selection) bool {
|
||||
href, _ := s.Attr("href")
|
||||
if href == "/html/j_links/Jenna_Leigh_c/" || href == "/html/a_links/Alexa_Grace_c/" {
|
||||
return false
|
||||
}
|
||||
if strings.ToLower(s.Text()) == strings.ToLower(performerName) {
|
||||
return true
|
||||
}
|
||||
alias := s.ParentsFiltered(".babeNameBlock").Find(".babeAlias").First();
|
||||
if strings.Contains( strings.ToLower(alias.Text()), strings.ToLower(performerName) ) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
href, _ := performerLink.Attr("href")
|
||||
href = strings.TrimSuffix(href, "/")
|
||||
regex := regexp.MustCompile(`.+_links\/(.+)`)
|
||||
matches := regex.FindStringSubmatch(href)
|
||||
if len(matches) < 2 {
|
||||
return nil, fmt.Errorf("No matches found in %s",href)
|
||||
}
|
||||
|
||||
href = strings.Replace(href, matches[1], "bio_"+matches[1]+".php", -1)
|
||||
href = "https://www.freeones.com" + href
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func getPerformerBio(c scraperTypeConfig, href string) (*models.ScrapedPerformer, error) {
|
||||
bioRes, err := http.Get(href)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer bioRes.Body.Close()
|
||||
if res.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("status code error: %d %s", res.StatusCode, res.Status)
|
||||
if bioRes.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("status code error: %d %s", bioRes.StatusCode, bioRes.Status)
|
||||
}
|
||||
|
||||
// Load the HTML document
|
||||
@@ -175,6 +181,57 @@ func GetPerformer(performerName string) (*models.ScrapedPerformer, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func GetPerformer(c scraperTypeConfig, scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error) {
|
||||
if scrapedPerformer.Name == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
performerName := *scrapedPerformer.Name
|
||||
queryURL := "https://www.freeones.com/search/?t=1&q=" + url.PathEscape(performerName) + "&view=thumbs"
|
||||
res, err := http.Get(queryURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("status code error: %d %s", res.StatusCode, res.Status)
|
||||
}
|
||||
|
||||
// Load the HTML document
|
||||
doc, err := goquery.NewDocumentFromReader(res.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
performerLink := doc.Find("div.Block3 a").FilterFunction(func(i int, s *goquery.Selection) bool {
|
||||
href, _ := s.Attr("href")
|
||||
if href == "/html/j_links/Jenna_Leigh_c/" || href == "/html/a_links/Alexa_Grace_c/" {
|
||||
return false
|
||||
}
|
||||
if strings.ToLower(s.Text()) == strings.ToLower(performerName) {
|
||||
return true
|
||||
}
|
||||
alias := s.ParentsFiltered(".babeNameBlock").Find(".babeAlias").First()
|
||||
if strings.Contains(strings.ToLower(alias.Text()), strings.ToLower(performerName)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
href, _ := performerLink.Attr("href")
|
||||
href = strings.TrimSuffix(href, "/")
|
||||
regex := regexp.MustCompile(`.+_links\/(.+)`)
|
||||
matches := regex.FindStringSubmatch(href)
|
||||
if len(matches) < 2 {
|
||||
return nil, fmt.Errorf("No matches found in %s", href)
|
||||
}
|
||||
|
||||
href = strings.Replace(href, matches[1], "bio_"+matches[1]+".php", -1)
|
||||
href = "https://www.freeones.com" + href
|
||||
|
||||
return getPerformerBio(c, href)
|
||||
}
|
||||
|
||||
func getIndexes(doc *goquery.Document) map[string]int {
|
||||
var indexes = make(map[string]int)
|
||||
doc.Find(".paramname").Each(func(i int, s *goquery.Selection) {
|
||||
@@ -236,7 +293,7 @@ func paramValue(params *goquery.Selection, paramIndex int) string {
|
||||
return content
|
||||
}
|
||||
node = node.NextSibling
|
||||
if (node == nil) {
|
||||
if node == nil {
|
||||
return ""
|
||||
}
|
||||
return trim(node.FirstChild.Data)
|
||||
|
||||
251
pkg/scraper/scrapers.go
Normal file
251
pkg/scraper/scrapers.go
Normal file
@@ -0,0 +1,251 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
var scrapers []scraperConfig
|
||||
|
||||
func loadScrapers() ([]scraperConfig, error) {
|
||||
if scrapers != nil {
|
||||
return scrapers, nil
|
||||
}
|
||||
|
||||
path := config.GetScrapersPath()
|
||||
scrapers = make([]scraperConfig, 0)
|
||||
|
||||
logger.Debugf("Reading scraper configs from %s", path)
|
||||
scraperFiles, err := filepath.Glob(filepath.Join(path, "*.yml"))
|
||||
|
||||
if err != nil {
|
||||
logger.Errorf("Error reading scraper configs: %s", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// add built-in freeones scraper
|
||||
scrapers = append(scrapers, GetFreeonesScraper())
|
||||
|
||||
for _, file := range scraperFiles {
|
||||
scraper, err := loadScraperFromYAML(file)
|
||||
if err != nil {
|
||||
logger.Errorf("Error loading scraper %s: %s", file, err.Error())
|
||||
} else {
|
||||
scrapers = append(scrapers, *scraper)
|
||||
}
|
||||
}
|
||||
|
||||
return scrapers, nil
|
||||
}
|
||||
|
||||
func ListPerformerScrapers() ([]*models.Scraper, error) {
|
||||
// read scraper config files from the directory and cache
|
||||
scrapers, err := loadScrapers()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ret []*models.Scraper
|
||||
for _, s := range scrapers {
|
||||
// filter on type
|
||||
if s.supportsPerformers() {
|
||||
ret = append(ret, s.toScraper())
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func ListSceneScrapers() ([]*models.Scraper, error) {
|
||||
// read scraper config files from the directory and cache
|
||||
scrapers, err := loadScrapers()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ret []*models.Scraper
|
||||
for _, s := range scrapers {
|
||||
// filter on type
|
||||
if s.supportsScenes() {
|
||||
ret = append(ret, s.toScraper())
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func findScraper(scraperID string) *scraperConfig {
|
||||
// read scraper config files from the directory and cache
|
||||
loadScrapers()
|
||||
|
||||
for _, s := range scrapers {
|
||||
if s.ID == scraperID {
|
||||
return &s
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ScrapePerformerList(scraperID string, query string) ([]*models.ScrapedPerformer, error) {
|
||||
// find scraper with the provided id
|
||||
s := findScraper(scraperID)
|
||||
if s != nil {
|
||||
return s.ScrapePerformerNames(query)
|
||||
}
|
||||
|
||||
return nil, errors.New("Scraper with ID " + scraperID + " not found")
|
||||
}
|
||||
|
||||
func ScrapePerformer(scraperID string, scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error) {
|
||||
// find scraper with the provided id
|
||||
s := findScraper(scraperID)
|
||||
if s != nil {
|
||||
return s.ScrapePerformer(scrapedPerformer)
|
||||
}
|
||||
|
||||
return nil, errors.New("Scraper with ID " + scraperID + " not found")
|
||||
}
|
||||
|
||||
func ScrapePerformerURL(url string) (*models.ScrapedPerformer, error) {
|
||||
for _, s := range scrapers {
|
||||
if s.matchesPerformerURL(url) {
|
||||
return s.ScrapePerformerURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func matchPerformer(p *models.ScrapedScenePerformer) error {
|
||||
qb := models.NewPerformerQueryBuilder()
|
||||
|
||||
performers, err := qb.FindByNames([]string{p.Name}, nil)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(performers) != 1 {
|
||||
// ignore - cannot match
|
||||
return nil
|
||||
}
|
||||
|
||||
id := strconv.Itoa(performers[0].ID)
|
||||
p.ID = &id
|
||||
return nil
|
||||
}
|
||||
|
||||
func matchStudio(s *models.ScrapedSceneStudio) error {
|
||||
qb := models.NewStudioQueryBuilder()
|
||||
|
||||
studio, err := qb.FindByName(s.Name, nil)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if studio == nil {
|
||||
// ignore - cannot match
|
||||
return nil
|
||||
}
|
||||
|
||||
id := strconv.Itoa(studio.ID)
|
||||
s.ID = &id
|
||||
return nil
|
||||
}
|
||||
|
||||
func matchTag(s *models.ScrapedSceneTag) error {
|
||||
qb := models.NewTagQueryBuilder()
|
||||
|
||||
tag, err := qb.FindByName(s.Name, nil)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if tag == nil {
|
||||
// ignore - cannot match
|
||||
return nil
|
||||
}
|
||||
|
||||
id := strconv.Itoa(tag.ID)
|
||||
s.ID = &id
|
||||
return nil
|
||||
}
|
||||
|
||||
func postScrapeScene(ret *models.ScrapedScene) error {
|
||||
for _, p := range ret.Performers {
|
||||
err := matchPerformer(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, t := range ret.Tags {
|
||||
err := matchTag(t)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if ret.Studio != nil {
|
||||
err := matchStudio(ret.Studio)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ScrapeScene(scraperID string, scene models.SceneUpdateInput) (*models.ScrapedScene, error) {
|
||||
// find scraper with the provided id
|
||||
s := findScraper(scraperID)
|
||||
if s != nil {
|
||||
ret, err := s.ScrapeScene(scene)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if ret != nil {
|
||||
err = postScrapeScene(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
return nil, errors.New("Scraper with ID " + scraperID + " not found")
|
||||
}
|
||||
|
||||
func ScrapeSceneURL(url string) (*models.ScrapedScene, error) {
|
||||
for _, s := range scrapers {
|
||||
if s.matchesSceneURL(url) {
|
||||
ret, err := s.ScrapeSceneURL(url)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = postScrapeScene(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
132
pkg/scraper/script.go
Normal file
132
pkg/scraper/script.go
Normal file
@@ -0,0 +1,132 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
func runScraperScript(command []string, inString string, out interface{}) error {
|
||||
cmd := exec.Command(command[0], command[1:]...)
|
||||
cmd.Dir = config.GetScrapersPath()
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer stdin.Close()
|
||||
|
||||
io.WriteString(stdin, inString)
|
||||
}()
|
||||
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
logger.Error("Scraper stderr not available: " + err.Error())
|
||||
}
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if nil != err {
|
||||
logger.Error("Scraper stdout not available: " + err.Error())
|
||||
}
|
||||
|
||||
if err = cmd.Start(); err != nil {
|
||||
logger.Error("Error running scraper script: " + err.Error())
|
||||
return errors.New("Error running scraper script")
|
||||
}
|
||||
|
||||
// TODO - add a timeout here
|
||||
decodeErr := json.NewDecoder(stdout).Decode(out)
|
||||
|
||||
stderrData, _ := ioutil.ReadAll(stderr)
|
||||
stderrString := string(stderrData)
|
||||
|
||||
err = cmd.Wait()
|
||||
|
||||
if err != nil {
|
||||
// error message should be in the stderr stream
|
||||
logger.Errorf("scraper error when running command <%s>: %s", strings.Join(cmd.Args, " "), stderrString)
|
||||
return errors.New("Error running scraper script")
|
||||
}
|
||||
|
||||
if decodeErr != nil {
|
||||
logger.Errorf("error decoding performer from scraper data: %s", err.Error())
|
||||
return errors.New("Error decoding performer from scraper script")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func scrapePerformerNamesScript(c scraperTypeConfig, name string) ([]*models.ScrapedPerformer, error) {
|
||||
inString := `{"name": "` + name + `"}`
|
||||
|
||||
var performers []models.ScrapedPerformer
|
||||
|
||||
err := runScraperScript(c.Script, inString, &performers)
|
||||
|
||||
// convert to pointers
|
||||
var ret []*models.ScrapedPerformer
|
||||
if err == nil {
|
||||
for i := 0; i < len(performers); i++ {
|
||||
ret = append(ret, &performers[i])
|
||||
}
|
||||
}
|
||||
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func scrapePerformerFragmentScript(c scraperTypeConfig, scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error) {
|
||||
inString, err := json.Marshal(scrapedPerformer)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ret models.ScrapedPerformer
|
||||
|
||||
err = runScraperScript(c.Script, string(inString), &ret)
|
||||
|
||||
return &ret, err
|
||||
}
|
||||
|
||||
func scrapePerformerURLScript(c scraperTypeConfig, url string) (*models.ScrapedPerformer, error) {
|
||||
inString := `{"url": "` + url + `"}`
|
||||
|
||||
var ret models.ScrapedPerformer
|
||||
|
||||
err := runScraperScript(c.Script, string(inString), &ret)
|
||||
|
||||
return &ret, err
|
||||
}
|
||||
|
||||
func scrapeSceneFragmentScript(c scraperTypeConfig, scene models.SceneUpdateInput) (*models.ScrapedScene, error) {
|
||||
inString, err := json.Marshal(scene)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ret models.ScrapedScene
|
||||
|
||||
err = runScraperScript(c.Script, string(inString), &ret)
|
||||
|
||||
return &ret, err
|
||||
}
|
||||
|
||||
func scrapeSceneURLScript(c scraperTypeConfig, url string) (*models.ScrapedScene, error) {
|
||||
inString := `{"url": "` + url + `"}`
|
||||
|
||||
var ret models.ScrapedScene
|
||||
|
||||
err := runScraperScript(c.Script, string(inString), &ret)
|
||||
|
||||
return &ret, err
|
||||
}
|
||||
132
pkg/scraper/stash.go
Normal file
132
pkg/scraper/stash.go
Normal file
@@ -0,0 +1,132 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/shurcooL/graphql"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
func getStashClient(c scraperTypeConfig) *graphql.Client {
|
||||
url := c.scraperConfig.StashServer.URL
|
||||
return graphql.NewClient(url+"/graphql", nil)
|
||||
}
|
||||
|
||||
type stashFindPerformerNamePerformer struct {
|
||||
ID string `json:"id" graphql:"id"`
|
||||
Name string `json:"id" graphql:"name"`
|
||||
}
|
||||
|
||||
func (p stashFindPerformerNamePerformer) toPerformer() *models.ScrapedPerformer {
|
||||
return &models.ScrapedPerformer{
|
||||
Name: &p.Name,
|
||||
// put id into the URL field
|
||||
URL: &p.ID,
|
||||
}
|
||||
}
|
||||
|
||||
type stashFindPerformerNamesResultType struct {
|
||||
Count int `graphql:"count"`
|
||||
Performers []*stashFindPerformerNamePerformer `graphql:"performers"`
|
||||
}
|
||||
|
||||
func scrapePerformerNamesStash(c scraperTypeConfig, name string) ([]*models.ScrapedPerformer, error) {
|
||||
client := getStashClient(c)
|
||||
|
||||
var q struct {
|
||||
FindPerformers stashFindPerformerNamesResultType `graphql:"findPerformers(filter: $f)"`
|
||||
}
|
||||
|
||||
page := 1
|
||||
perPage := 10
|
||||
|
||||
vars := map[string]interface{}{
|
||||
"f": models.FindFilterType{
|
||||
Q: &name,
|
||||
Page: &page,
|
||||
PerPage: &perPage,
|
||||
},
|
||||
}
|
||||
|
||||
err := client.Query(context.Background(), &q, vars)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ret []*models.ScrapedPerformer
|
||||
for _, p := range q.FindPerformers.Performers {
|
||||
ret = append(ret, p.toPerformer())
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func scrapePerformerFragmentStash(c scraperTypeConfig, scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error) {
|
||||
client := getStashClient(c)
|
||||
|
||||
var q struct {
|
||||
FindPerformer *models.ScrapedPerformer `graphql:"findPerformer(id: $f)"`
|
||||
}
|
||||
|
||||
// get the id from the URL field
|
||||
vars := map[string]interface{}{
|
||||
"f": *scrapedPerformer.URL,
|
||||
}
|
||||
|
||||
err := client.Query(context.Background(), &q, vars)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return q.FindPerformer, nil
|
||||
}
|
||||
|
||||
func scrapeSceneFragmentStash(c scraperTypeConfig, scene models.SceneUpdateInput) (*models.ScrapedScene, error) {
|
||||
// query by MD5
|
||||
// assumes that the scene exists in the database
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
id, err := strconv.Atoi(scene.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
storedScene, err := qb.Find(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var q struct {
|
||||
FindScene *models.ScrapedScene `graphql:"findScene(checksum: $c)"`
|
||||
}
|
||||
|
||||
checksum := graphql.String(storedScene.Checksum)
|
||||
vars := map[string]interface{}{
|
||||
"c": &checksum,
|
||||
}
|
||||
|
||||
client := getStashClient(c)
|
||||
err = client.Query(context.Background(), &q, vars)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if q.FindScene != nil {
|
||||
// the ids of the studio, performers and tags must be nilled
|
||||
if q.FindScene.Studio != nil {
|
||||
q.FindScene.Studio.ID = nil
|
||||
}
|
||||
|
||||
for _, p := range q.FindScene.Performers {
|
||||
p.ID = nil
|
||||
}
|
||||
|
||||
for _, t := range q.FindScene.Tags {
|
||||
t.ID = nil
|
||||
}
|
||||
}
|
||||
|
||||
return q.FindScene, nil
|
||||
}
|
||||
494
pkg/scraper/xpath.go
Normal file
494
pkg/scraper/xpath.go
Normal file
@@ -0,0 +1,494 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/antchfx/htmlquery"
|
||||
"golang.org/x/net/html"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
type commonXPathConfig map[string]string
|
||||
|
||||
func (c commonXPathConfig) applyCommon(src string) string {
|
||||
ret := src
|
||||
for commonKey, commonVal := range c {
|
||||
if strings.Contains(ret, commonKey) {
|
||||
ret = strings.Replace(ret, commonKey, commonVal, -1)
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type xpathScraperConfig map[string]interface{}
|
||||
|
||||
func createXPathScraperConfig(src map[interface{}]interface{}) xpathScraperConfig {
|
||||
ret := make(xpathScraperConfig)
|
||||
|
||||
if src != nil {
|
||||
for k, v := range src {
|
||||
keyStr, isStr := k.(string)
|
||||
if isStr {
|
||||
ret[keyStr] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type xpathRegexConfig map[interface{}]interface{}
|
||||
type xpathRegexConfigs []xpathRegexConfig
|
||||
|
||||
func (c xpathRegexConfig) apply(value string) string {
|
||||
regex := ""
|
||||
with := ""
|
||||
|
||||
if regexI, _ := c["regex"]; regexI != nil {
|
||||
regex, _ = regexI.(string)
|
||||
}
|
||||
if withI, _ := c["with"]; withI != nil {
|
||||
with, _ = withI.(string)
|
||||
}
|
||||
|
||||
if regex != "" {
|
||||
re, err := regexp.Compile(regex)
|
||||
if err != nil {
|
||||
logger.Warnf("Error compiling regex '%s': %s", regex, err.Error())
|
||||
return value
|
||||
}
|
||||
|
||||
return re.ReplaceAllString(value, with)
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func (c xpathRegexConfigs) apply(value string) string {
|
||||
// apply regex in order
|
||||
for _, config := range c {
|
||||
value = config.apply(value)
|
||||
}
|
||||
|
||||
// remove whitespace again
|
||||
value = commonPostProcess(value)
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
type xpathScraperAttrConfig map[interface{}]interface{}
|
||||
|
||||
func (c xpathScraperAttrConfig) getString(key string) string {
|
||||
ret, _ := c[key]
|
||||
|
||||
if ret == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
asStr, _ := ret.(string)
|
||||
return asStr
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getSelector() string {
|
||||
const selectorKey = "selector"
|
||||
return c.getString(selectorKey)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getConcat() string {
|
||||
const concatKey = "concat"
|
||||
return c.getString(concatKey)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) hasConcat() bool {
|
||||
return c.getConcat() != ""
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getParseDate() string {
|
||||
const parseDateKey = "parseDate"
|
||||
return c.getString(parseDateKey)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getReplace() xpathRegexConfigs {
|
||||
const replaceKey = "replace"
|
||||
val, _ := c[replaceKey]
|
||||
|
||||
var ret xpathRegexConfigs
|
||||
if val == nil {
|
||||
return ret
|
||||
}
|
||||
|
||||
asSlice, _ := val.([]interface{})
|
||||
|
||||
for _, v := range asSlice {
|
||||
asMap, _ := v.(map[interface{}]interface{})
|
||||
ret = append(ret, xpathRegexConfig(asMap))
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) concatenateResults(nodes []*html.Node) string {
|
||||
separator := c.getConcat()
|
||||
result := []string{}
|
||||
|
||||
for _, elem := range nodes {
|
||||
text := htmlquery.InnerText(elem)
|
||||
text = commonPostProcess(text)
|
||||
|
||||
result = append(result, text)
|
||||
}
|
||||
|
||||
return strings.Join(result, separator)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) parseDate(value string) string {
|
||||
parseDate := c.getParseDate()
|
||||
|
||||
if parseDate == "" {
|
||||
return value
|
||||
}
|
||||
|
||||
// try to parse the date using the pattern
|
||||
// if it fails, then just fall back to the original value
|
||||
parsedValue, err := time.Parse(parseDate, value)
|
||||
if err != nil {
|
||||
logger.Warnf("Error parsing date string '%s' using format '%s': %s", value, parseDate, err.Error())
|
||||
return value
|
||||
}
|
||||
|
||||
// convert it into our date format
|
||||
const internalDateFormat = "2006-01-02"
|
||||
return parsedValue.Format(internalDateFormat)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) replaceRegex(value string) string {
|
||||
replace := c.getReplace()
|
||||
return replace.apply(value)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) postProcess(value string) string {
|
||||
// perform regex replacements first
|
||||
value = c.replaceRegex(value)
|
||||
value = c.parseDate(value)
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func commonPostProcess(value string) string {
|
||||
value = strings.TrimSpace(value)
|
||||
|
||||
// remove multiple whitespace and end lines
|
||||
re := regexp.MustCompile("\n")
|
||||
value = re.ReplaceAllString(value, "")
|
||||
re = regexp.MustCompile(" +")
|
||||
value = re.ReplaceAllString(value, " ")
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func runXPathQuery(doc *html.Node, xpath string, common commonXPathConfig) []*html.Node {
|
||||
// apply common
|
||||
if common != nil {
|
||||
xpath = common.applyCommon(xpath)
|
||||
}
|
||||
|
||||
found, err := htmlquery.QueryAll(doc, xpath)
|
||||
if err != nil {
|
||||
logger.Warnf("Error parsing xpath expression '%s': %s", xpath, err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
return found
|
||||
}
|
||||
|
||||
func (s xpathScraperConfig) process(doc *html.Node, common commonXPathConfig) xPathResults {
|
||||
var ret xPathResults
|
||||
|
||||
for k, value := range s {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
found := runXPathQuery(doc, v, common)
|
||||
|
||||
if len(found) > 0 {
|
||||
for i, elem := range found {
|
||||
text := htmlquery.InnerText(elem)
|
||||
text = commonPostProcess(text)
|
||||
|
||||
ret = ret.setKey(i, k, text)
|
||||
}
|
||||
}
|
||||
case map[interface{}]interface{}:
|
||||
attrConfig := xpathScraperAttrConfig(v)
|
||||
|
||||
found := runXPathQuery(doc, attrConfig.getSelector(), common)
|
||||
|
||||
if len(found) > 0 {
|
||||
// check if we're concatenating the results into a single result
|
||||
if attrConfig.hasConcat() {
|
||||
result := attrConfig.concatenateResults(found)
|
||||
result = attrConfig.postProcess(result)
|
||||
const i = 0
|
||||
ret = ret.setKey(i, k, result)
|
||||
} else {
|
||||
for i, elem := range found {
|
||||
text := htmlquery.InnerText(elem)
|
||||
text = commonPostProcess(text)
|
||||
text = attrConfig.postProcess(text)
|
||||
|
||||
ret = ret.setKey(i, k, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type xpathScrapers map[string]*xpathScraper
|
||||
|
||||
type xpathScraper struct {
|
||||
Common commonXPathConfig `yaml:"common"`
|
||||
Scene xpathScraperConfig `yaml:"scene"`
|
||||
Performer xpathScraperConfig `yaml:"performer"`
|
||||
}
|
||||
|
||||
const (
|
||||
XPathScraperConfigSceneTags = "Tags"
|
||||
XPathScraperConfigScenePerformers = "Performers"
|
||||
XPathScraperConfigSceneStudio = "Studio"
|
||||
)
|
||||
|
||||
func (s xpathScraper) GetSceneSimple() xpathScraperConfig {
|
||||
// exclude the complex sub-configs
|
||||
ret := make(xpathScraperConfig)
|
||||
mapped := s.Scene
|
||||
|
||||
if mapped != nil {
|
||||
for k, v := range mapped {
|
||||
if k != XPathScraperConfigSceneTags && k != XPathScraperConfigScenePerformers && k != XPathScraperConfigSceneStudio {
|
||||
ret[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s xpathScraper) getSceneSubMap(key string) xpathScraperConfig {
|
||||
var ret map[interface{}]interface{}
|
||||
mapped := s.Scene
|
||||
|
||||
if mapped != nil {
|
||||
v, ok := mapped[key]
|
||||
if ok {
|
||||
ret, _ = v.(map[interface{}]interface{})
|
||||
}
|
||||
}
|
||||
|
||||
if ret != nil {
|
||||
return createXPathScraperConfig(ret)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s xpathScraper) GetScenePerformers() xpathScraperConfig {
|
||||
return s.getSceneSubMap(XPathScraperConfigScenePerformers)
|
||||
}
|
||||
|
||||
func (s xpathScraper) GetSceneTags() xpathScraperConfig {
|
||||
return s.getSceneSubMap(XPathScraperConfigSceneTags)
|
||||
}
|
||||
|
||||
func (s xpathScraper) GetSceneStudio() xpathScraperConfig {
|
||||
return s.getSceneSubMap(XPathScraperConfigSceneStudio)
|
||||
}
|
||||
|
||||
func (s xpathScraper) scrapePerformer(doc *html.Node) (*models.ScrapedPerformer, error) {
|
||||
var ret models.ScrapedPerformer
|
||||
|
||||
performerMap := s.Performer
|
||||
if performerMap == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
results := performerMap.process(doc, s.Common)
|
||||
if len(results) > 0 {
|
||||
results[0].apply(&ret)
|
||||
}
|
||||
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s xpathScraper) scrapePerformers(doc *html.Node) ([]*models.ScrapedPerformer, error) {
|
||||
var ret []*models.ScrapedPerformer
|
||||
|
||||
performerMap := s.Performer
|
||||
if performerMap == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
results := performerMap.process(doc, s.Common)
|
||||
for _, r := range results {
|
||||
var p models.ScrapedPerformer
|
||||
r.apply(&p)
|
||||
ret = append(ret, &p)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (s xpathScraper) scrapeScene(doc *html.Node) (*models.ScrapedScene, error) {
|
||||
var ret models.ScrapedScene
|
||||
|
||||
sceneMap := s.GetSceneSimple()
|
||||
if sceneMap == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
scenePerformersMap := s.GetScenePerformers()
|
||||
sceneTagsMap := s.GetSceneTags()
|
||||
sceneStudioMap := s.GetSceneStudio()
|
||||
|
||||
results := sceneMap.process(doc, s.Common)
|
||||
if len(results) > 0 {
|
||||
results[0].apply(&ret)
|
||||
|
||||
// now apply the performers and tags
|
||||
if scenePerformersMap != nil {
|
||||
performerResults := scenePerformersMap.process(doc, s.Common)
|
||||
|
||||
for _, p := range performerResults {
|
||||
performer := &models.ScrapedScenePerformer{}
|
||||
p.apply(performer)
|
||||
ret.Performers = append(ret.Performers, performer)
|
||||
}
|
||||
}
|
||||
|
||||
if sceneTagsMap != nil {
|
||||
tagResults := sceneTagsMap.process(doc, s.Common)
|
||||
|
||||
for _, p := range tagResults {
|
||||
tag := &models.ScrapedSceneTag{}
|
||||
p.apply(tag)
|
||||
ret.Tags = append(ret.Tags, tag)
|
||||
}
|
||||
}
|
||||
|
||||
if sceneStudioMap != nil {
|
||||
studioResults := sceneStudioMap.process(doc, s.Common)
|
||||
|
||||
if len(studioResults) > 0 {
|
||||
studio := &models.ScrapedSceneStudio{}
|
||||
studioResults[0].apply(studio)
|
||||
ret.Studio = studio
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
type xPathResult map[string]string
|
||||
type xPathResults []xPathResult
|
||||
|
||||
func (r xPathResult) apply(dest interface{}) {
|
||||
destVal := reflect.ValueOf(dest)
|
||||
|
||||
// dest should be a pointer
|
||||
destVal = destVal.Elem()
|
||||
|
||||
for key, value := range r {
|
||||
field := destVal.FieldByName(key)
|
||||
|
||||
if field.IsValid() {
|
||||
var reflectValue reflect.Value
|
||||
if field.Kind() == reflect.Ptr {
|
||||
// need to copy the value, otherwise everything is set to the
|
||||
// same pointer
|
||||
localValue := value
|
||||
reflectValue = reflect.ValueOf(&localValue)
|
||||
} else {
|
||||
reflectValue = reflect.ValueOf(value)
|
||||
}
|
||||
|
||||
field.Set(reflectValue)
|
||||
} else {
|
||||
logger.Errorf("Field %s does not exist in %T", key, dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (r xPathResults) setKey(index int, key string, value string) xPathResults {
|
||||
if index >= len(r) {
|
||||
r = append(r, make(xPathResult))
|
||||
}
|
||||
|
||||
r[index][key] = value
|
||||
return r
|
||||
}
|
||||
|
||||
func scrapePerformerURLXpath(c scraperTypeConfig, url string) (*models.ScrapedPerformer, error) {
|
||||
scraper := c.scraperConfig.XPathScrapers[c.Scraper]
|
||||
|
||||
if scraper == nil {
|
||||
return nil, errors.New("xpath scraper with name " + c.Scraper + " not found in config")
|
||||
}
|
||||
|
||||
doc, err := htmlquery.LoadURL(url)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return scraper.scrapePerformer(doc)
|
||||
}
|
||||
|
||||
func scrapeSceneURLXPath(c scraperTypeConfig, url string) (*models.ScrapedScene, error) {
|
||||
scraper := c.scraperConfig.XPathScrapers[c.Scraper]
|
||||
|
||||
if scraper == nil {
|
||||
return nil, errors.New("xpath scraper with name " + c.Scraper + " not found in config")
|
||||
}
|
||||
|
||||
doc, err := htmlquery.LoadURL(url)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return scraper.scrapeScene(doc)
|
||||
}
|
||||
|
||||
func scrapePerformerNamesXPath(c scraperTypeConfig, name string) ([]*models.ScrapedPerformer, error) {
|
||||
scraper := c.scraperConfig.XPathScrapers[c.Scraper]
|
||||
|
||||
if scraper == nil {
|
||||
return nil, errors.New("xpath scraper with name " + c.Scraper + " not found in config")
|
||||
}
|
||||
|
||||
const placeholder = "{}"
|
||||
|
||||
// replace the placeholder string with the URL-escaped name
|
||||
escapedName := url.QueryEscape(name)
|
||||
|
||||
u := c.QueryURL
|
||||
u = strings.Replace(u, placeholder, escapedName, -1)
|
||||
|
||||
doc, err := htmlquery.LoadURL(u)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return scraper.scrapePerformers(doc)
|
||||
}
|
||||
822
pkg/scraper/xpath_test.go
Normal file
822
pkg/scraper/xpath_test.go
Normal file
@@ -0,0 +1,822 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/antchfx/htmlquery"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// adapted from https://www.freeones.com/html/m_links/bio_Mia_Malkova.php
|
||||
const htmlDoc1 = `
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
|
||||
<head>
|
||||
<title>Freeones: Mia Malkova Biography</title>
|
||||
</head>
|
||||
<body data-babe="Mia Malkova">
|
||||
<div class="ContentBlock Block1">
|
||||
<div class="ContentBlockBody" style="padding: 0px;">
|
||||
<table id="biographyTable" border="0" cellspacing="0" cellpadding="0" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<div><b>Babe Name:</b></div>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
<a href="/html/m_links/Mia_Malkova/">Mia Malkova</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<div><b>Profession:</b></div>
|
||||
</td>
|
||||
<td class="paramvalue">Porn Star
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Ethnicity:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
Caucasian
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Country of Origin:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
|
||||
<span class="country-us">
|
||||
|
||||
United States
|
||||
<span>
|
||||
</span></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Date of Birth:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
July 1, 1992 (27 years old)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Aliases:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
Mia Bliss, Madison Clover, Madison Swan, Mia Mountain, Jessica
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Eye Color:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
Hazel
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Hair Color:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
Blonde
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Height:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
heightcm = "171";
|
||||
morethenone = 'inch';
|
||||
feet = heightcm / 30.48;
|
||||
inches = (feet - Math.floor(feet)) * 30.48 / 2.54;
|
||||
|
||||
feet = Math.floor(feet);
|
||||
inches = inches.toFixed(0);
|
||||
|
||||
if (inches > 1) {
|
||||
morethenone = 'inches';
|
||||
}
|
||||
|
||||
if (heightcm == 0) {
|
||||
message = 'Unknown';
|
||||
} else {
|
||||
message = '171 cm - ' + feet + ' feet and ' + inches + ' ' + morethenone;
|
||||
}
|
||||
document.write(message);
|
||||
// -->
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Measurements:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
34C-26-36
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Fake boobs:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
No
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Career Start And End</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
2012 - 2019
|
||||
(7 Years In The Business)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Tattoos:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
None
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<b>Piercings:</b>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
None
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramname">
|
||||
<div><b>Social Network Links:</b></div>
|
||||
</td>
|
||||
<td class="paramvalue">
|
||||
<ul id="socialmedia">
|
||||
<li class="twitter"><a href="https://twitter.com/MiaMalkova" target="_blank" alt="Mia Malkova Twitter" title="Mia Malkova Twitter">Twitter</a></li>
|
||||
<li class="facebook"><a href="https://www.facebook.com/MiaMalcove" target="_blank" alt="Mia Malkova Facebook" title="Mia Malkova Facebook">Facebook</a></li>
|
||||
<li class="youtube"><a href="https://www.youtube.com/channel/UCEPR0sZKa_ScMoyhemfB7nA" target="_blank" alt="Mia Malkova YouTube" title="Mia Malkova YouTube">YouTube</a></li>
|
||||
<li class="instagram"><a href="https://www.instagram.com/mia_malkova/" target="_blank" alt="Mia Malkova Instagram" title="Mia Malkova Instagram">Instagram</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
||||
func makeCommonXPath(attr string) string {
|
||||
return `//table[@id="biographyTable"]//tr/td[@class="paramname"]//b[text() = '` + attr + `']/ancestor::tr/td[@class="paramvalue"]`
|
||||
}
|
||||
|
||||
func makeReplaceRegex(regex string, with string) map[interface{}]interface{} {
|
||||
ret := make(map[interface{}]interface{})
|
||||
|
||||
ret["regex"] = regex
|
||||
ret["with"] = with
|
||||
return ret
|
||||
}
|
||||
|
||||
func makeXPathConfig() xpathScraperConfig {
|
||||
config := make(xpathScraperConfig)
|
||||
|
||||
config["Name"] = makeCommonXPath("Babe Name:") + `/a`
|
||||
config["Ethnicity"] = makeCommonXPath("Ethnicity:")
|
||||
config["Country"] = makeCommonXPath("Country of Origin:")
|
||||
config["Aliases"] = makeCommonXPath("Aliases:")
|
||||
config["EyeColor"] = makeCommonXPath("Eye Color:")
|
||||
config["Measurements"] = makeCommonXPath("Measurements:")
|
||||
config["FakeTits"] = makeCommonXPath("Fake boobs:")
|
||||
config["Height"] = makeCommonXPath("Height:")
|
||||
config["Tattoos"] = makeCommonXPath("Tattoos:")
|
||||
config["Piercings"] = makeCommonXPath("Piercings:")
|
||||
|
||||
// special handling for birthdate
|
||||
birthdateAttrConfig := make(map[interface{}]interface{})
|
||||
birthdateAttrConfig["selector"] = makeCommonXPath("Date of Birth:")
|
||||
|
||||
var birthdateReplace []interface{}
|
||||
birthdateReplace = append(birthdateReplace, makeReplaceRegex(` \(.* years old\)`, ""))
|
||||
|
||||
birthdateAttrConfig["replace"] = birthdateReplace
|
||||
birthdateAttrConfig["parseDate"] = "January 2, 2006" // "July 1, 1992 (27 years old) "
|
||||
config["Birthdate"] = birthdateAttrConfig
|
||||
|
||||
// special handling for career length
|
||||
careerLengthAttrConfig := make(map[interface{}]interface{})
|
||||
// no colon in attribute header
|
||||
careerLengthAttrConfig["selector"] = makeCommonXPath("Career Start And End")
|
||||
|
||||
var careerLengthReplace []interface{}
|
||||
careerLengthReplace = append(careerLengthReplace, makeReplaceRegex(`\s+\(.*\)`, ""))
|
||||
careerLengthAttrConfig["replace"] = careerLengthReplace
|
||||
|
||||
config["CareerLength"] = careerLengthAttrConfig
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
func verifyField(t *testing.T, expected string, actual *string, field string) {
|
||||
t.Helper()
|
||||
|
||||
if actual == nil || *actual != expected {
|
||||
if actual == nil {
|
||||
t.Errorf("Expected %s to be set to %s, instead got nil", field, expected)
|
||||
} else {
|
||||
t.Errorf("Expected %s to be set to %s, instead got %s", field, expected, *actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestScrapePerformerXPath(t *testing.T) {
|
||||
reader := strings.NewReader(htmlDoc1)
|
||||
doc, err := htmlquery.Parse(reader)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error loading document: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
xpathConfig := makeXPathConfig()
|
||||
|
||||
scraper := xpathScraper{
|
||||
Performer: xpathConfig,
|
||||
}
|
||||
|
||||
performer, err := scraper.scrapePerformer(doc)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error scraping performer: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
const performerName = "Mia Malkova"
|
||||
const ethnicity = "Caucasian"
|
||||
const country = "United States"
|
||||
const birthdate = "1992-07-01"
|
||||
const aliases = "Mia Bliss, Madison Clover, Madison Swan, Mia Mountain, Jessica"
|
||||
const eyeColor = "Hazel"
|
||||
const measurements = "34C-26-36"
|
||||
const fakeTits = "No"
|
||||
const careerLength = "2012 - 2019"
|
||||
const tattoosPiercings = "None"
|
||||
|
||||
verifyField(t, performerName, performer.Name, "Name")
|
||||
verifyField(t, ethnicity, performer.Ethnicity, "Ethnicity")
|
||||
verifyField(t, country, performer.Country, "Country")
|
||||
|
||||
verifyField(t, birthdate, performer.Birthdate, "Birthdate")
|
||||
|
||||
verifyField(t, aliases, performer.Aliases, "Aliases")
|
||||
verifyField(t, eyeColor, performer.EyeColor, "EyeColor")
|
||||
verifyField(t, measurements, performer.Measurements, "Measurements")
|
||||
verifyField(t, fakeTits, performer.FakeTits, "FakeTits")
|
||||
|
||||
verifyField(t, careerLength, performer.CareerLength, "CareerLength")
|
||||
|
||||
verifyField(t, tattoosPiercings, performer.Tattoos, "Tattoos")
|
||||
verifyField(t, tattoosPiercings, performer.Piercings, "Piercings")
|
||||
}
|
||||
|
||||
func TestConcatXPath(t *testing.T) {
|
||||
const firstName = "FirstName"
|
||||
const lastName = "LastName"
|
||||
const eyeColor = "EyeColor"
|
||||
const separator = " "
|
||||
const testDoc = `
|
||||
<html>
|
||||
<div>` + firstName + `</div>
|
||||
<div>` + lastName + `</div>
|
||||
<span>` + eyeColor + `</span>
|
||||
</html>
|
||||
`
|
||||
|
||||
reader := strings.NewReader(testDoc)
|
||||
doc, err := htmlquery.Parse(reader)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error loading document: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
xpathConfig := make(xpathScraperConfig)
|
||||
nameAttrConfig := make(map[interface{}]interface{})
|
||||
nameAttrConfig["selector"] = "//div"
|
||||
nameAttrConfig["concat"] = separator
|
||||
xpathConfig["Name"] = nameAttrConfig
|
||||
xpathConfig["EyeColor"] = "//span"
|
||||
|
||||
scraper := xpathScraper{
|
||||
Performer: xpathConfig,
|
||||
}
|
||||
|
||||
performer, err := scraper.scrapePerformer(doc)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error scraping performer: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
const performerName = firstName + separator + lastName
|
||||
|
||||
verifyField(t, performerName, performer.Name, "Name")
|
||||
verifyField(t, eyeColor, performer.EyeColor, "EyeColor")
|
||||
}
|
||||
|
||||
const sceneHTML = `
|
||||
<!DOCTYPE html>
|
||||
|
||||
<head>
|
||||
<title>Test Video - Pornhub.com</title>
|
||||
|
||||
<meta property="og:title" content="Test Video" />
|
||||
<meta property="og:description"
|
||||
content="Watch Test Video on Pornhub.com, the best hardcore porn site. Pornhub is home to the widest selection of free Babe sex videos full of the hottest pornstars. If you're craving 3some XXX movies you'll find them here." />
|
||||
<meta property="og:image"
|
||||
content="https://di.phncdn.com/videos/201910/13/254476211/thumbs_80/(m=eaAaGwObaaaa)(mh=_V1YEGdMFS1rEYoW)9.jpg" />
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "VideoObject",
|
||||
"name": "Test Video",
|
||||
"embedUrl": "https://www.pornhub.com/embed/ph5da270596459c",
|
||||
"duration": "PT00H33M27S",
|
||||
"thumbnailUrl": "https://di.phncdn.com/videos/201910/13/254476211/thumbs_80/(m=eaAaGwObaaaa)(mh=_V1YEGdMFS1rEYoW)9.jpg",
|
||||
"uploadDate": "2019-10-13T00:33:51+00:00",
|
||||
"description": "Watch Test Video on Pornhub.com, the best hardcore porn site. Pornhub is home to the widest selection of free Babe sex videos full of the hottest pornstars. If you're craving 3some XXX movies you'll find them here.",
|
||||
"author" : "Mia Malkova", "interactionStatistic": [
|
||||
{
|
||||
"@type": "InteractionCounter",
|
||||
"interactionType": "http://schema.org/WatchAction",
|
||||
"userInteractionCount": "5,908,861"
|
||||
},
|
||||
{
|
||||
"@type": "InteractionCounter",
|
||||
"interactionType": "http://schema.org/LikeAction",
|
||||
"userInteractionCount": "22,090"
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="logged-out">
|
||||
<div class="container ">
|
||||
|
||||
|
||||
<div id="main-container" class="clearfix" data-delete-check="1" data-is-private="1" data-is-premium=""
|
||||
data-liu="0" data-next-shuffle="ph5da270596459c" data-pkey="" data-platform-pc="1" data-playlist-check="0"
|
||||
data-playlist-id-check="0" data-playlist-geo-check="0" data-friend="0" data-playlist-user-check="0"
|
||||
data-playlist-video-check="0" data-playlist-shuffle="0" data-shuffle-forward="ph5da270596459c"
|
||||
data-shuffle-back="ph5da270596459c" data-min-large="1350"
|
||||
data-video-title="Test Video">
|
||||
|
||||
<div id="vpContentContainer">
|
||||
<div id="hd-leftColVideoPage">
|
||||
<div class="video-wrapper">
|
||||
<div class="title-container">
|
||||
<i class="isMe tooltipTrig" data-title="Video of verified member"></i>
|
||||
<h1 class="title">
|
||||
<span class="inlineFree">Test Video</span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="video-actions-container">
|
||||
<div class="video-actions-tabs">
|
||||
<div class="video-action-tab about-tab active">
|
||||
<div class="video-detailed-info">
|
||||
<div class="video-info-row">
|
||||
From:
|
||||
|
||||
<div class="usernameWrap clearfix" data-type="channel" data-userid="492538092"
|
||||
data-liu-user="0"
|
||||
data-json-url="/user/box?id=492538092&token=MTU3NzA1NTkzNIqATol8v_WrhmNTXkeflvG09C2U7UUT_NyoZUFa7iKq0mlzBkmdgAH1aNHZkJmIOHbbwmho1BehHDoA63K5Wn4."
|
||||
data-disable-popover="0">
|
||||
|
||||
<a rel="" href="/channels/sis-loves-me" class="bolded">Sis Loves Me</a>
|
||||
<div class="avatarPosition"></div>
|
||||
</div>
|
||||
|
||||
<span class="verified-icon flag tooltipTrig"
|
||||
data-title="Verified member"></span>
|
||||
- 87 videos
|
||||
<span class="subscribers-count"> 459466</span>
|
||||
</div>
|
||||
|
||||
<div class="video-info-row">
|
||||
<div class="pornstarsWrapper">
|
||||
Pornstars:
|
||||
<a class="pstar-list-btn js-mxp" data-mxptype="Pornstar"
|
||||
data-mxptext="Alex D" data-id="251341" data-login="1"
|
||||
href="/pornstar/alex-d">Alex D <span
|
||||
class="psbox-link-container display-none"></span>
|
||||
</a>
|
||||
, <a class="pstar-list-btn js-mxp" data-mxptype="Pornstar"
|
||||
data-mxptext="Mia Malkova" data-id="10641" data-login="1"
|
||||
href="/pornstar/mia-malkova">Mia Malkova <span
|
||||
class="psbox-link-container display-none"></span>
|
||||
</a>
|
||||
, <a class="pstar-list-btn js-mxp" data-mxptype="Pornstar"
|
||||
data-mxptext="Riley Reid" data-id="5343" data-login="1"
|
||||
href="/pornstar/riley-reid">Riley Reid <span
|
||||
class="psbox-link-container display-none"></span>
|
||||
</a>
|
||||
<div class="tooltipTrig suggestBtn" data-title="Add a pornstar">
|
||||
<a class="add-btn-small add-pornstar-btn-2">+
|
||||
<span>Suggest</span></a>
|
||||
</div>
|
||||
<div id="deletePornstarResult" class="suggest-result"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="video-info-row showLess">
|
||||
<div class="categoriesWrapper">
|
||||
Categories:
|
||||
<a href="/video?c=3"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Amateur</a>,
|
||||
<a href="/categories/babe"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Babe</a>,
|
||||
<a href="/video?c=13"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Blowjob</a>,
|
||||
<a href="/video?c=115"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Exclusive</a>,
|
||||
<a href="/hd"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">HD
|
||||
Porn</a>, <a href="/categories/pornstar"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Pornstar</a>,
|
||||
<a href="/video?c=24"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Public</a>,
|
||||
<a href="/video?c=131"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Pussy
|
||||
Licking</a>, <a href="/video?c=65"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Threesome</a>,
|
||||
<a href="/video?c=139"
|
||||
onclick="ga('send', 'event', 'Watch Page', 'click', 'Category');">Verified
|
||||
Models</a>
|
||||
<div class="tooltipTrig suggestBtn" data-title="Suggest Categories">
|
||||
<a id="categoryLink" class="add-btn-small ">+
|
||||
<span>Suggest</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="video-info-row showLess">
|
||||
<div class="productionWrapper">
|
||||
Production:
|
||||
<a href="/video?p=professional" rel="nofollow"
|
||||
class="production">professional</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="video-info-row showLess">
|
||||
<div class="tagsWrapper">
|
||||
Tags:
|
||||
<a href="/video/search?search=3some">3some</a>, <a
|
||||
href="/video?c=9">blonde</a>, <a href="/video?c=59">small tits</a>,
|
||||
<a href="/video/search?search=butt">butt</a>, <a
|
||||
href="/video/search?search=natural+tits">natural tits</a>, <a
|
||||
href="/video/search?search=petite">petite</a>, <a
|
||||
href="/video?c=24">public</a>, <a
|
||||
href="/video/search?search=outside">outside</a>, <a
|
||||
href="/video/search?search=car">car</a>, <a
|
||||
href="/video/search?search=garage">garage</a>, <a
|
||||
href="/video?c=65">threesome</a>, <a
|
||||
href="/video/search?search=bgg">bgg</a>, <a
|
||||
href="/video/search?search=girlfrien+d">girlfrien d</a>, <a
|
||||
href="/video/search?search=parking">parking</a>, <a
|
||||
href="/video/search?search=sex">sex</a>, <a
|
||||
href="/video/search?search=gagging">gagging</a>, <a
|
||||
href="/video?c=13">blowjob</a>, <a
|
||||
href="/video/search?search=bj">bj</a>, <a
|
||||
href="/video/search?search=double">double</a>, <a
|
||||
href="/video/search?search=ass">ass</a>
|
||||
<div class="tooltipTrig suggestBtn" data-title="Suggest Tags">
|
||||
<a id="tagLink" class="add-btn-small">+ <span>Suggest</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="video-info-row showLess">
|
||||
Added on: <span class="white">2 months ago</span>
|
||||
</div>
|
||||
|
||||
<div class="video-info-row showLess">
|
||||
Featured on: <span class="white">1 month ago</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="video-action-tab jump-to-tab">
|
||||
<div class="title">Jump to your favorite action</div>
|
||||
|
||||
<div class="filters mainFilter float-right">
|
||||
<div class="dropdownTrigger">
|
||||
<div>
|
||||
<span class="textFilter" id="tagSort">Sequence</span>
|
||||
<span class="arrowFilters"></span>
|
||||
</div>
|
||||
<ul class="filterListItem dropdownWrapper">
|
||||
<li class="active"><a class="actionTagSort"
|
||||
data-sort="seconds">Sequence</a></li>
|
||||
<li><a class="actionTagSort" data-sort="tag">Alphabetical</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="reset"></div>
|
||||
<div class="display-grid col-4 gap-row-none sortBy seconds">
|
||||
<ul class="actionTagList full-width margin-none">
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(862), ga('send', 'event', 'Video Page', 'click', 'Jump to Blowjob');">
|
||||
Blowjob </a>
|
||||
|
||||
<var>14:22</var>
|
||||
</li>
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1117), ga('send', 'event', 'Video Page', 'click', 'Jump to Reverse Cowgirl');">
|
||||
Reverse Cowgirl </a>
|
||||
|
||||
<var>18:37</var>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="actionTagList full-width margin-none">
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1182), ga('send', 'event', 'Video Page', 'click', 'Jump to Cowgirl');">
|
||||
Cowgirl </a>
|
||||
|
||||
<var>19:42</var>
|
||||
</li>
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1625), ga('send', 'event', 'Video Page', 'click', 'Jump to Cowgirl');">
|
||||
Cowgirl </a>
|
||||
|
||||
<var>27:05</var>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="actionTagList full-width margin-none">
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1822), ga('send', 'event', 'Video Page', 'click', 'Jump to Doggystyle');">
|
||||
Doggystyle </a>
|
||||
|
||||
<var>30:22</var>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="display-grid col-4 gap-row-none sortBy tag">
|
||||
<ul class="actionTagList full-width margin-none">
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(862), ga('send', 'event', 'Video Page', 'click', 'Jump to Blowjob');">
|
||||
Blowjob </a>
|
||||
|
||||
<var>14:22</var>
|
||||
</li>
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1117), ga('send', 'event', 'Video Page', 'click', 'Jump to Reverse Cowgirl');">
|
||||
Reverse Cowgirl </a>
|
||||
|
||||
<var>18:37</var>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="actionTagList full-width margin-none">
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1182), ga('send', 'event', 'Video Page', 'click', 'Jump to Cowgirl');">
|
||||
Cowgirl </a>
|
||||
|
||||
<var>19:42</var>
|
||||
</li>
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1625), ga('send', 'event', 'Video Page', 'click', 'Jump to Cowgirl');">
|
||||
Cowgirl </a>
|
||||
|
||||
<var>27:05</var>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="actionTagList full-width margin-none">
|
||||
<li>
|
||||
<a class="js-triggerJumpCat"
|
||||
onclick="jumpToAction(1822), ga('send', 'event', 'Video Page', 'click', 'Jump to Doggystyle');">
|
||||
Doggystyle </a>
|
||||
|
||||
<var>30:22</var>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
func makeSceneXPathConfig() xpathScraper {
|
||||
common := make(commonXPathConfig)
|
||||
|
||||
common["$performerElem"] = `//div[@class="pornstarsWrapper"]/a[@data-mxptype="Pornstar"]`
|
||||
common["$studioElem"] = `//div[@data-type="channel"]/a`
|
||||
|
||||
config := make(xpathScraperConfig)
|
||||
|
||||
config["Title"] = `//meta[@property="og:title"]/@content`
|
||||
// this needs post-processing
|
||||
config["Date"] = `//script[@type="application/ld+json"]`
|
||||
|
||||
tagConfig := make(map[interface{}]interface{})
|
||||
tagConfig["Name"] = `//div[@class="categoriesWrapper"]//a[not(@class="add-btn-small ")]`
|
||||
config["Tags"] = tagConfig
|
||||
|
||||
performerConfig := make(map[interface{}]interface{})
|
||||
performerConfig["Name"] = `$performerElem/@data-mxptext`
|
||||
performerConfig["URL"] = `$performerElem/@href`
|
||||
config["Performers"] = performerConfig
|
||||
|
||||
studioConfig := make(map[interface{}]interface{})
|
||||
studioConfig["Name"] = `$studioElem`
|
||||
studioConfig["URL"] = `$studioElem/@href`
|
||||
config["Studio"] = studioConfig
|
||||
|
||||
scraper := xpathScraper{
|
||||
Scene: config,
|
||||
Common: common,
|
||||
}
|
||||
|
||||
return scraper
|
||||
}
|
||||
|
||||
func verifyTags(t *testing.T, expectedTagNames []string, actualTags []*models.ScrapedSceneTag) {
|
||||
t.Helper()
|
||||
|
||||
i := 0
|
||||
for i < len(expectedTagNames) || i < len(actualTags) {
|
||||
expectedTag := ""
|
||||
actualTag := ""
|
||||
if i < len(expectedTagNames) {
|
||||
expectedTag = expectedTagNames[i]
|
||||
}
|
||||
if i < len(actualTags) {
|
||||
actualTag = actualTags[i].Name
|
||||
}
|
||||
|
||||
if expectedTag != actualTag {
|
||||
t.Errorf("Expected tag %s, got %s", expectedTag, actualTag)
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func verifyPerformers(t *testing.T, expectedNames []string, expectedURLs []string, actualPerformers []*models.ScrapedScenePerformer) {
|
||||
t.Helper()
|
||||
|
||||
i := 0
|
||||
for i < len(expectedNames) || i < len(actualPerformers) {
|
||||
expectedName := ""
|
||||
actualName := ""
|
||||
expectedURL := ""
|
||||
actualURL := ""
|
||||
if i < len(expectedNames) {
|
||||
expectedName = expectedNames[i]
|
||||
}
|
||||
if i < len(expectedURLs) {
|
||||
expectedURL = expectedURLs[i]
|
||||
}
|
||||
if i < len(actualPerformers) {
|
||||
actualName = actualPerformers[i].Name
|
||||
if actualPerformers[i].URL != nil {
|
||||
actualURL = *actualPerformers[i].URL
|
||||
}
|
||||
}
|
||||
|
||||
if expectedName != actualName {
|
||||
t.Errorf("Expected performer name %s, got %s", expectedName, actualName)
|
||||
}
|
||||
if expectedURL != actualURL {
|
||||
t.Errorf("Expected perfromer URL %s, got %s", expectedName, actualName)
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplySceneXPathConfig(t *testing.T) {
|
||||
reader := strings.NewReader(sceneHTML)
|
||||
doc, err := htmlquery.Parse(reader)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error loading document: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
scraper := makeSceneXPathConfig()
|
||||
|
||||
scene, err := scraper.scrapeScene(doc)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error scraping scene: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
const title = "Test Video"
|
||||
|
||||
verifyField(t, title, scene.Title, "Title")
|
||||
|
||||
// verify tags
|
||||
expectedTags := []string{
|
||||
"Amateur",
|
||||
"Babe",
|
||||
"Blowjob",
|
||||
"Exclusive",
|
||||
"HD Porn",
|
||||
"Pornstar",
|
||||
"Public",
|
||||
"Pussy Licking",
|
||||
"Threesome",
|
||||
"Verified Models",
|
||||
}
|
||||
verifyTags(t, expectedTags, scene.Tags)
|
||||
|
||||
expectedPerformerNames := []string{
|
||||
"Alex D",
|
||||
"Mia Malkova",
|
||||
"Riley Reid",
|
||||
}
|
||||
|
||||
expectedPerformerURLs := []string{
|
||||
"/pornstar/alex-d",
|
||||
"/pornstar/mia-malkova",
|
||||
"/pornstar/riley-reid",
|
||||
}
|
||||
|
||||
verifyPerformers(t, expectedPerformerNames, expectedPerformerURLs, scene.Performers)
|
||||
|
||||
const expectedStudioName = "Sis Loves Me"
|
||||
const expectedStudioURL = "/channels/sis-loves-me"
|
||||
|
||||
verifyField(t, expectedStudioName, &scene.Studio.Name, "Studio.Name")
|
||||
verifyField(t, expectedStudioURL, scene.Studio.URL, "Studio.URL")
|
||||
}
|
||||
|
||||
func TestLoadXPathScraperFromYAML(t *testing.T) {
|
||||
const yamlStr = `name: Test
|
||||
performerByURL:
|
||||
- action: scrapeXPath
|
||||
url:
|
||||
- test.com
|
||||
scraper: performerScraper
|
||||
xPathScrapers:
|
||||
performerScraper:
|
||||
performer:
|
||||
name: //h1[@itemprop="name"]
|
||||
`
|
||||
|
||||
config := &scraperConfig{}
|
||||
err := yaml.Unmarshal([]byte(yamlStr), &config)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error loading yaml: %s", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadInvalidXPath(t *testing.T) {
|
||||
config := make(xpathScraperConfig)
|
||||
|
||||
config["Name"] = `//a[id=']/span`
|
||||
|
||||
reader := strings.NewReader(htmlDoc1)
|
||||
doc, err := htmlquery.Parse(reader)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error loading document: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
common := make(commonXPathConfig)
|
||||
config.process(doc, common)
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// GetVTTTime returns a timestamp appropriate for VTT files (hh:mm:ss)
|
||||
// GetVTTTime returns a timestamp appropriate for VTT files (hh:mm:ss.mmm)
|
||||
func GetVTTTime(totalSeconds float64) (s string) {
|
||||
totalSecondsString := strconv.FormatFloat(totalSeconds, 'f', -1, 64)
|
||||
secondsDuration, _ := time.ParseDuration(totalSecondsString + "s")
|
||||
@@ -34,5 +34,8 @@ func GetVTTTime(totalSeconds float64) (s string) {
|
||||
}
|
||||
s += strconv.Itoa(seconds)
|
||||
|
||||
// videojs requires milliseconds
|
||||
s += ".000"
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
DATE=`go run scripts/getDate.go`
|
||||
DATE=`go run -mod=vendor scripts/getDate.go`
|
||||
GITHASH=`git rev-parse --short HEAD`
|
||||
VERSION_FLAGS="-X 'github.com/stashapp/stash/pkg/api.buildstamp=$DATE' -X 'github.com/stashapp/stash/pkg/api.githash=$GITHASH'"
|
||||
|
||||
STASH_VERSION=`git describe --tags --exclude latest_develop`
|
||||
VERSION_FLAGS="-X 'github.com/stashapp/stash/pkg/api.version=$STASH_VERSION' -X 'github.com/stashapp/stash/pkg/api.buildstamp=$DATE' -X 'github.com/stashapp/stash/pkg/api.githash=$GITHASH'"
|
||||
SETUP="export GO111MODULE=on; export CGO_ENABLED=1;"
|
||||
WINDOWS="GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ packr2 build -o dist/stash-win.exe -ldflags \"-extldflags '-static' $VERSION_FLAGS\" -tags extended -v -mod=vendor;"
|
||||
DARWIN="GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ packr2 build -o dist/stash-osx -ldflags \"$VERSION_FLAGS\" -tags extended -v -mod=vendor;"
|
||||
@@ -12,4 +12,4 @@ RASPPI="GOOS=linux GOARCH=arm GOARM=5 CC=arm-linux-gnueabi-gcc packr2 build -o d
|
||||
|
||||
COMMAND="$SETUP $WINDOWS $DARWIN $LINUX $RASPPI"
|
||||
|
||||
docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash stashapp/stash:compiler /bin/bash -c "$COMMAND"
|
||||
docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash stashapp/compiler:develop /bin/bash -c "$COMMAND"
|
||||
|
||||
15
scripts/upload-pull-request.sh
Normal file
15
scripts/upload-pull-request.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# assumes cross-compile.sh has already been run successfully
|
||||
uploadFile()
|
||||
{
|
||||
FILE=$1
|
||||
BASENAME="$(basename "${FILE}")"
|
||||
# abort if it takes more than two minutes to upload
|
||||
uploadedTo=`curl -m 120 --upload-file $FILE "https://transfer.sh/$BASENAME"`
|
||||
echo "$BASENAME uploaded to url: $uploadedTo"
|
||||
}
|
||||
|
||||
uploadFile "dist/stash-osx"
|
||||
uploadFile "dist/stash-win.exe"
|
||||
uploadFile "dist/stash-linux"
|
||||
7
tools.go
Normal file
7
tools.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// +build tools
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "github.com/99designs/gqlgen"
|
||||
)
|
||||
@@ -31,10 +31,9 @@
|
||||
"react-jw-player": "1.19.0",
|
||||
"react-photo-gallery": "7.0.2",
|
||||
"react-router-dom": "5.0.0",
|
||||
"react-scripts": "3.0.1",
|
||||
"react-scripts": "3.3.0",
|
||||
"react-use": "9.1.2",
|
||||
"subscriptions-transport-ws": "^0.9.16",
|
||||
"video.js": "^7.6.0"
|
||||
"subscriptions-transport-ws": "^0.9.16"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user