@@ -25,7 +25,8 @@ def processScene(scene):
2525 getTag ("[TPDBMarker]" )
2626 for sid in scene ["stash_ids" ]:
2727 if sid ["endpoint" ] == TPDB_ENDPOINT :
28- log .debug ("Scene has a TPDB stash id, looking up %s " % (sid ["stash_id" ],))
28+ log .debug ("Scene has a TPDB stash id, looking up %s " %
29+ (sid ["stash_id" ],))
2930 res = request_s .get (
3031 "https://api.theporndb.net/scenes/%s" % (sid ["stash_id" ],)
3132 )
@@ -55,19 +56,23 @@ def processScene(scene):
5556 log .info ("Saving markers" )
5657 if settings ["overwriteMarkers" ]:
5758 stash .destroy_scene_markers (scene ["id" ])
58- mp .import_scene_markers (stash , markers , scene ["id" ], 15 )
59+ mp .import_scene_markers (
60+ stash , markers , scene ["id" ], 15 )
5961 elif (len (scene ["scene_markers" ]) == 0 or settings ["mergeMarkers" ]):
60- mp .import_scene_markers (stash , markers , scene ["id" ], 15 )
62+ mp .import_scene_markers (
63+ stash , markers , scene ["id" ], 15 )
6164 # skip if there is already a movie linked
6265 if settings ["createMovieFromScene" ] and len (scene .get ("movies" , [])) == 0 :
63- movies = []
66+ movies = []
6467 for m in data ["movies" ]:
65- movie = processMovie (m )
68+ movie = processMovie (m )
6669 if movie :
67- movies .append ({"movie_id" : movie ["id" ],"scene_index" :None })
70+ movies .append (
71+ {"movie_id" : movie ["id" ], "scene_index" : None })
6872 log .debug (movies )
6973 if len (movies ) > 0 :
70- stash .update_scene ({'id' :scene ["id" ],"movies" :movies })
74+ stash .update_scene (
75+ {'id' : scene ["id" ], "movies" : movies })
7176 else :
7277 log .error ('bad response from tpdb: %s' % (res .status_code ,))
7378
@@ -76,7 +81,8 @@ def processScene(scene):
7681
7782def processAll ():
7883 log .info ("Getting scene count" )
79- skip_sync_tag_id = stash .find_tag ("[TPDB: Skip Marker]" , create = True ).get ("id" )
84+ skip_sync_tag_id = stash .find_tag (
85+ "[TPDB: Skip Marker]" , create = True ).get ("id" )
8086 f = {
8187 "stash_id_endpoint" : {
8288 "endpoint" : TPDB_ENDPOINT ,
@@ -127,50 +133,47 @@ def processAll():
127133 log .progress ((i / count ))
128134 time .sleep (1 )
129135
136+
130137def processMovie (m ):
131138 log .debug (m )
132139 log .debug (m .keys ())
133140 # check if the movie exists with the url, then match to the scene
134141 sm = stash .find_groups (
135- f = {
136- "url" : {
137- "modifier" : "EQUALS" ,
138- "value" : m ["url" ],
142+ f = {
143+ "url" : {
144+ "modifier" : "EQUALS" ,
145+ "value" : m ["url" ],
146+ }
139147 }
140- }
141148 )
142149 log .debug ("sm: %s" % (sm ,))
143- if len (sm ) > 0 :
150+ if len (sm ) > 0 :
144151 return sm [0 ]
145152 # find the movie by name
146- sm = stash .find_groups (q = m ['title' ])
153+ sm = stash .find_groups (q = m ['title' ])
147154 for mov in sm :
148- if mov ['name' ]== m ['title' ]:
149- return mov
150-
155+ if mov ['name' ] == m ['title' ]:
156+ return mov
151157
152158 # just create the movie with the details from tpdb
153- new_movie = {
154- 'name' : m ['title' ],
155- 'date' : m ['date' ],
156- 'synopsis' : m ['description' ],
157- 'front_image' : m ['image' ],
158- 'back_image' : m ['back_image' ],
159- 'urls' : [m ['url' ]],
159+ new_movie = {
160+ 'name' : m ['title' ],
161+ 'date' : m ['date' ],
162+ 'synopsis' : m ['description' ],
163+ 'front_image' : m ['image' ],
164+ 'back_image' : m ['back_image' ],
165+ 'urls' : [m ['url' ]],
160166 }
161167 if m ['site' ]:
162- studio = stash .find_studio (m ['site' ],create = True )
168+ studio = stash .find_studio (m ['site' ], create = True )
163169 if studio :
164- new_movie ['studio_id' ]= studio ['id' ]
170+ new_movie ['studio_id' ] = studio ['id' ]
165171
166- mov = stash .create_movie (new_movie )
172+ mov = stash .create_movie (new_movie )
167173 log .debug (mov )
168174 return mov
169175
170176
171-
172-
173-
174177json_input = json .loads (sys .stdin .read ())
175178
176179FRAGMENT_SERVER = json_input ["server_connection" ]
@@ -179,7 +182,7 @@ def processMovie(m):
179182config = stash .get_configuration ()["plugins" ]
180183settings = {
181184 "disableSceneMarkerHook" : False ,
182- "createMovieFromScene" :True ,
185+ "createMovieFromScene" : True ,
183186 "addTPDBMarkerTag" : False ,
184187 "addTPDBMarkerTitle" : False ,
185188 "runOnScenesWithMarkers" : False ,
@@ -202,15 +205,18 @@ def processMovie(m):
202205 PLUGIN_ARGS = json_input ["args" ]["mode" ]
203206 if "processScene" == PLUGIN_ARGS :
204207 if "scene_id" in json_input ["args" ]:
205- scene = stash .find_scene (json_input ["args" ]["scene_id" ], fragment = 'id urls stash_ids {endpoint stash_id} tags {id} interactive files { path duration fingerprint(type: "phash")}' )
208+ scene = stash .find_scene (
209+ json_input ["args" ]["scene_id" ],
210+ fragment = 'id urls stash_ids {endpoint stash_id} tags {id} interactive files { path duration fingerprint(type: "phash")}' )
206211 processScene (scene )
207212 else :
208213 processAll ()
209214 elif "hookContext" in json_input ["args" ]:
210215 _id = json_input ["args" ]["hookContext" ]["id" ]
211216 _type = json_input ["args" ]["hookContext" ]["type" ]
212217 if _type == "Scene.Update.Post" and not settings ["disableSceneMarkerHook" ]:
213- stash .run_plugin_task ("TPDBMarkers" , "Sync" , args = {"scene_id" : _id })
218+ stash .run_plugin_task ("TPDBMarkers" , "Sync" ,
219+ args = {"scene_id" : _id })
214220# scene = stash.find_scene(_id)
215221# processScene(scene)
216222
0 commit comments