Skip to content

Commit

Permalink
final corrections for 1.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
NevermindNilas committed Mar 16, 2024
1 parent 61818ac commit c49c892
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 36 deletions.
63 changes: 29 additions & 34 deletions TheAnimeScripter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,29 +272,32 @@ var TheAnimeScripter = (function() {
var sceneChangeSensValue = function() { return labelValues["SceneChange"]; };
var dedupSensValue = function() { return labelValues["DedupSens"]; };

var group4 = generalPanel.add("group", undefined, {
name: "group4"
});
function createCheckbox(panel, text, name, defaultValue, helpTip) {
var group = panel.add("group", undefined, { name: "group" + name });
group.orientation = "row";
group.alignChildren = ["left", "center"];
group.spacing = 45;
group.margins = 0;

group4.orientation = "row";
group4.alignChildren = ["left", "center"];
group4.spacing = 45;
group4.margins = 0;
var checkbox = group.add("checkbox", undefined, text, { name: name });
checkbox.alignment = ["left", "center"];
checkbox.helpTip = helpTip;
checkbox.value = defaultValue;

var checkboxEnsemble = group4.add("checkbox", undefined, "Rife Ensemble", {
name: "checkboxEnsemble"
});
checkbox.onClick = function() {
checkboxValues[name] = checkbox.value;
}

checkboxEnsemble.alignment = ["left", "center"];
checkboxEnsemble.helpTip = "Turn on ensemble for Rife, higher quality outputs for a slight tax in performance";
checkboxValues[name] = defaultValue;

var checkboxYTDLPQuality = group4.add("checkbox", undefined, "YT-DLP 4K", {
name: "checkboxYTDLPQuality"
});
return function() {
return checkboxValues[name];
};
}

var checkboxEnsembleValue = function() { return checkboxValues["Ensemble"]; };
var checkboxYTDLPQualityValue = function() { return checkboxValues["YTDLPQuality"]; };

checkboxYTDLPQuality.alignment = ["left", "center"];
checkboxYTDLPQuality.helpTip = "Turn on higher quality download for YT-DLP, will download the highest quality available from yt (4k/8k) and then re-encode the video to the desired encoder, turn off for 1920x1080p only downloads";

var fieldValues = {}
function createMultiplierField(panel, text, name, defaultValue) {
var group = panel.add("group", undefined, { name: "group" + name });
Expand Down Expand Up @@ -517,13 +520,6 @@ var TheAnimeScripter = (function() {
}

buttonStartProcess.onClick = function() {
if (checkboxDeduplicate.value == false && checkboxUpscale.value == false && checkboxInterpolate.value == false && checkboxSharpen.value == false) {
if (checkboxResize.value == false) {
alert("Please select at least one of the checkboxes");
return;
}
}

startChain();
}

Expand Down Expand Up @@ -642,11 +638,6 @@ var TheAnimeScripter = (function() {
return;
}

if (app.preferences.getPrefAsLong("Main Pref Section v2", "Pref_SCRIPTING_FILE_NETWORK_SECURITY") != 1) {
alert("Please tick the \"Allow Scripts to Write Files and Access Network\" checkbox in Scripting & Expressions");
return app.executeCommand(2359);
}

var exeFile = theAnimeScripterPath + "\\main.exe";
var exeFilePath = new File(exeFile);
if (!exeFilePath.exists) {
Expand Down Expand Up @@ -756,15 +747,19 @@ var TheAnimeScripter = (function() {
break;
} else {
var maxAttempts = 3;
var importSuccessful = false;
for (var attempt = 0; attempt < maxAttempts; attempt++) {
if (importSuccessful) {
break;
}
$.sleep(1000); // Sleeping for a second, metadata is not always written instantly
try {
var importOptions = new ImportOptions(File(output_name));
var importOptions = new ImportOptions(File(outputName));
var importedFile = app.project.importFile(importOptions);
var inputLayer = comp.layers.add(importedFile);
inputLayer.startTime = layer.inPoint;
inputLayer.moveBefore(layer);
if (checkboxUpscale.value == true || checkboxResize.value == true) {
if (checkboxUpscaleValue() == true || checkboxResizeValue() == true) {
var compWidth = comp.width;
var compHeight = comp.height;
var layerWidth = inputLayer.source.width;
Expand All @@ -779,10 +774,10 @@ var TheAnimeScripter = (function() {
var scaleY = (layerHeight / inputLayer.source.height) * 100;
inputLayer.property("Scale").setValue([scaleX, scaleY, 100]);
}
break;
importSuccessful = true;
} catch (error) {
if (attempt == maxAttempts - 1) {
alert("Failed to import file after " + maxAttempts + " attempts: " + output_name);
alert("Failed to import file after " + maxAttempts + " attempts: " + outputName);
alert("Error: " + error.toString());
}
}
Expand Down
27 changes: 25 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import shutil
from importlib.metadata import distribution

from main import scriptVersion
base_dir = os.path.dirname(os.path.abspath(__file__))

outputName = "TAS" + scriptVersion + ".7z"

def create_venv():
print("Creating the virtual environment...")
Expand Down Expand Up @@ -37,7 +38,7 @@ def create_executable():
main_path = os.path.join(base_dir, "main.py")
icon_path = os.path.join(base_dir, "demos", "icon.ico")
rife_ncnn_models_path = os.path.join(
distribution("rife_ncnn_vulkan_python").locate_file("rife_ncnn_vulkan_python"),
distribution("rife_ncnn_vulkan_python_TAS").locate_file("rife_ncnn_vulkan_python"),
"models",
)

Expand Down Expand Up @@ -143,11 +144,32 @@ def clean_up():
shutil.rmtree(build_dir)
except Exception as e:
print("Error while removing the build directory: ", e)

try:
pycache_dir = os.path.join(base_dir, "__pycache__")
if os.path.exists(pycache_dir):
shutil.rmtree(pycache_dir)
except Exception as e:
print("Error while removing the pycache directory: ", e)

else:
print("Skipping Cleanup...")

print("Done!, you can find the built executable in the dist folder")

def compress_dist():
answer = input("Do you want to compress the dist directory? (y/n): ")

if answer.lower() == "y":
print("Installing 7z...")
subprocess.run([".\\venv\\Scripts\\python", "-m", "pip", "install", "py7zr"], check=True)

print("Compressing the dist directory...")
subprocess.run(["py", "-m", "py7zr", "c", outputName, "dist/"], check=True)
print("Done!, you can find the compressed file in the root directory")

else:
print("Skipping Compression...")

if __name__ == "__main__":
create_venv()
Expand All @@ -157,3 +179,4 @@ def clean_up():
create_executable()
move_extras()
clean_up()
compress_dist()

0 comments on commit c49c892

Please sign in to comment.