-
-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
228a5c5
commit 109e55a
Showing
7 changed files
with
84 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package scraper | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/stashapp/stash/pkg/models" | ||
) | ||
|
||
type queryURLReplacements map[string]mappedRegexConfigs | ||
|
||
type queryURLParameters map[string]string | ||
|
||
func queryURLParametersFromScene(scene *models.Scene) queryURLParameters { | ||
ret := make(queryURLParameters) | ||
ret["checksum"] = scene.Checksum.String | ||
ret["oshash"] = scene.OSHash.String | ||
ret["filename"] = filepath.Base(scene.Path) | ||
ret["title"] = scene.Title.String | ||
return ret | ||
} | ||
|
||
func queryURLParametersFromGallery(gallery *models.Gallery) queryURLParameters { | ||
ret := make(queryURLParameters) | ||
ret["checksum"] = gallery.Checksum | ||
|
||
if gallery.Path.Valid { | ||
ret["filename"] = filepath.Base(gallery.Path.String) | ||
} | ||
ret["title"] = gallery.Title.String | ||
|
||
return ret | ||
} | ||
|
||
func (p queryURLParameters) applyReplacements(r queryURLReplacements) { | ||
for k, v := range p { | ||
rpl, found := r[k] | ||
if found { | ||
p[k] = rpl.apply(v) | ||
} | ||
} | ||
} | ||
|
||
func (p queryURLParameters) constructURL(url string) string { | ||
ret := url | ||
for k, v := range p { | ||
ret = strings.Replace(ret, "{"+k+"}", v, -1) | ||
} | ||
|
||
return ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters