Skip to content

Commit

Permalink
Merge branch 'main' into preparebdsmrelease
Browse files Browse the repository at this point in the history
  • Loading branch information
skier233 authored Dec 3, 2024
2 parents 6cbc320 + 1262126 commit e0de14f
Show file tree
Hide file tree
Showing 35 changed files with 26,808 additions and 1,572 deletions.
2 changes: 1 addition & 1 deletion plugins/AITagger/ai_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def process_images_async(image_paths, threshold=config.IMAGE_THRESHOLD, re
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=config.SERVER_TIMEOUT)) as session:
return await post_api_async(session, 'process_images/', {"paths": image_paths, "threshold": threshold, "return_confidence": return_confidence})

async def process_video_async(video_path, frame_interval=config.FRAME_INTERVAL,threshold=config.AI_VIDEO_THRESHOLD, return_confidence=True ,vr_video=False):
async def process_video_async(video_path, vr_video=False, frame_interval=config.FRAME_INTERVAL,threshold=config.AI_VIDEO_THRESHOLD, return_confidence=True):
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=config.SERVER_TIMEOUT)) as session:
return await post_api_async(session, 'process_video/', {"path": video_path, "frame_interval": frame_interval, "threshold": threshold, "return_confidence": return_confidence, "vr_video": vr_video})

Expand Down
2 changes: 1 addition & 1 deletion plugins/AITagger/ai_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async def __tag_scene(scene):
vr_video = media_handler.is_vr_scene(scene.get('tags'))
if vr_video:
log.info(f"Processing VR video {scenePath}")
server_result = await ai_server.process_video_async(mutated_path, vr_video)
server_result = await ai_server.process_video_async(video_path=mutated_path, vr_video=vr_video)
if server_result is None:
log.error("Server returned no results")
media_handler.add_error_scene(sceneId)
Expand Down
25 changes: 20 additions & 5 deletions plugins/AITagger/media_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def initialize(connection):
# ----------------- Tag Methods -----------------


tag_categories = ["actions", "bodyparts"]
tag_categories = ["actions", "bodyparts", "bdsm", "clothing", "describingperson", "environment", "describingbody", "describingimage", "describingscene", "sextoys"]

def get_all_tags_from_server_result(result):
alltags = []
Expand Down Expand Up @@ -91,7 +91,11 @@ def remove_tagme_tags_from_images(image_ids):
def add_tags_to_image(image_id, tag_ids):
stash.update_images({"ids": [image_id], "tag_ids": {"ids": tag_ids, "mode": "ADD"}})

worker_counter = 0

def get_image_paths_and_ids(images):
global worker_counter
counter_updated = False
imagePaths = []
imageIds = []
temp_files = []
Expand All @@ -100,14 +104,25 @@ def get_image_paths_and_ids(images):
imagePath = image['files'][0]['path']
imageId = image['id']
if '.zip' in imagePath:
if not counter_updated:
worker_counter += 1
counter_updated = True
zip_index = imagePath.index('.zip') + 4
zip_path, img_path = imagePath[:zip_index], imagePath[zip_index+1:].replace('\\', '/')

# Create a unique temporary directory for this worker
temp_dir = os.path.join(config.temp_image_dir, f"worker_{worker_counter}")
os.makedirs(temp_dir, exist_ok=True)

temp_path = os.path.join(temp_dir, img_path)
os.makedirs(os.path.dirname(temp_path), exist_ok=True)

with zipfile.ZipFile(zip_path, 'r') as zip_ref:
temp_path = os.path.join(config.temp_image_dir, img_path)
os.makedirs(os.path.dirname(temp_path), exist_ok=True)
zip_ref.extract(img_path, config.temp_image_dir)
zip_ref.extract(img_path, temp_dir)
imagePath = os.path.abspath(os.path.normpath(temp_path))
temp_files.append(imagePath)

temp_files.append(temp_path)
temp_files.append(temp_dir) # Ensure the temp directory is also added to temp_files
imagePaths.append(imagePath)
imageIds.append(imageId)
except IndexError:
Expand Down
20 changes: 20 additions & 0 deletions plugins/CommunityScriptsUILibrary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ All the following functions are exposed under `window.csLib` and `csLib`
*/
```

## setConfiguration
```js
/**
* Set configuration of a plugin in the server via GraphQL
* @param {string} pluginId - The ID of the plugin as it is registered in the server
* @param {*} values - The configuration object with the values you want to save in the server
* @returns {Object} - The configuration object of the plugin as it is stored in the server after update
*
* @example
* // fetch config from the server
* const config = await getConfiguration('CommunityScriptsUIPlugin', defaultConfig);
* // config = { theme: 'dark' }
* // update the config based on user input
* // config = { theme: 'light' }
* // save config in the server
* await setConfiguration('CommunityScriptsUIPlugin', config);
* }
*/
```

## waitForElement
```js
/**
Expand Down
30 changes: 30 additions & 0 deletions plugins/CommunityScriptsUILibrary/cs-ui-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@
return response.configuration.plugins?.[pluginId] ?? fallback;
};

/**
* Set configuration of a plugin in the server via GraphQL
* @param {string} pluginId - The ID of the plugin as it is registered in the server
* @param {*} values - The configuration object with the values you want to save in the server
* @returns {Object} - The configuration object of the plugin as it is stored in the server after update
*
* @example
* // fetch config from the server
* const config = await getConfiguration('CommunityScriptsUIPlugin', defaultConfig);
* // config = { theme: 'dark' }
* // update the config based on user input
* // config = { theme: 'light' }
* // save config in the server
* await setConfiguration('CommunityScriptsUIPlugin', config);
* }
*/
const setConfiguration = async (pluginId, values) => {
const query = `mutation ConfigurePlugin($pluginId: ID!, $input: Map!) { configurePlugin(plugin_id: $pluginId, input: $input) }`;
const queryBody = {
query: query,
variables: {
pluginId: pluginId,
input: values,
},
};
const response = await csLib.callGQL({ ...queryBody });
return response.configurePlugin;
};

/**
* Waits for an element to be available in the DOM and runs the callback function once it is
* @param {string} selector - The CSS selector of the element to wait for
Expand Down Expand Up @@ -105,6 +134,7 @@
baseURL,
callGQL,
getConfiguration,
setConfiguration,
waitForElement,
PathElementListener,
};
Expand Down
67 changes: 67 additions & 0 deletions plugins/DupFileManager/DupFileManager.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/DupFileManager/DupFileManager.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

704 changes: 704 additions & 0 deletions plugins/DupFileManager/DupFileManager.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/DupFileManager/DupFileManager.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e0de14f

Please sign in to comment.