diff --git a/.dn/backup.conf b/.dn/backup.conf new file mode 100644 index 0000000..40a58c9 --- /dev/null +++ b/.dn/backup.conf @@ -0,0 +1,8 @@ +#Sun Oct 22 16:39:19 MSK 2023 +autoOpenTrigger= +autoCloseTrigger=1 +autoIntervalTriggerTime=240000 +masterDefault=dev +autoAmountMaxInSession=8 +autoIntervalTrigger=1 +autoAmountMax=12 diff --git a/.dn/bundles/develnext.bundle.httpclient.HttpClientBundle.conf b/.dn/bundles/develnext.bundle.httpclient.HttpClientBundle.conf new file mode 100644 index 0000000..eb9ab99 --- /dev/null +++ b/.dn/bundles/develnext.bundle.httpclient.HttpClientBundle.conf @@ -0,0 +1,4 @@ +#Sun Oct 22 16:39:19 MSK 2023 +version=1.0 +name=HTTP Client +env=all diff --git a/.dn/bundles/ide.bundle.std.JPHPDesktopDebugBundle.conf b/.dn/bundles/ide.bundle.std.JPHPDesktopDebugBundle.conf new file mode 100644 index 0000000..c271dde --- /dev/null +++ b/.dn/bundles/ide.bundle.std.JPHPDesktopDebugBundle.conf @@ -0,0 +1,2 @@ +#Sun Oct 22 16:39:19 MSK 2023 +env=dev diff --git a/.dn/bundles/ide.bundle.std.UIDesktopBundle.conf b/.dn/bundles/ide.bundle.std.UIDesktopBundle.conf new file mode 100644 index 0000000..7e58e10 --- /dev/null +++ b/.dn/bundles/ide.bundle.std.UIDesktopBundle.conf @@ -0,0 +1,2 @@ +#Sun Oct 22 16:39:19 MSK 2023 +env=all diff --git a/.dn/ide/editors/FormEditor/src/app/forms/MainForm.php.conf b/.dn/ide/editors/FormEditor/src/app/forms/MainForm.php.conf new file mode 100644 index 0000000..ca68585 --- /dev/null +++ b/.dn/ide/editors/FormEditor/src/app/forms/MainForm.php.conf @@ -0,0 +1,6 @@ +#Fri Oct 20 15:20:53 MSK 2023 +snapType=DOTS +blockedNodes= +zoom=100 +snapSizeY=8 +snapSizeX=8 diff --git a/.dn/ide/editors/ScriptModuleEditor/src/app/modules/AppModule.php.conf b/.dn/ide/editors/ScriptModuleEditor/src/app/modules/AppModule.php.conf new file mode 100644 index 0000000..3535c29 --- /dev/null +++ b/.dn/ide/editors/ScriptModuleEditor/src/app/modules/AppModule.php.conf @@ -0,0 +1,2 @@ +#Sun Oct 22 16:39:19 MSK 2023 +blockedNodes= diff --git a/.dn/ide/editors/ScriptModuleEditor/src/app/modules/MainModule.php.conf b/.dn/ide/editors/ScriptModuleEditor/src/app/modules/MainModule.php.conf new file mode 100644 index 0000000..372cf63 --- /dev/null +++ b/.dn/ide/editors/ScriptModuleEditor/src/app/modules/MainModule.php.conf @@ -0,0 +1,2 @@ +#Fri Oct 20 00:10:52 MSK 2023 +blockedNodes= diff --git a/.dn/ide/project/behaviours/BundleProjectBehaviour.conf b/.dn/ide/project/behaviours/BundleProjectBehaviour.conf new file mode 100644 index 0000000..b10c189 --- /dev/null +++ b/.dn/ide/project/behaviours/BundleProjectBehaviour.conf @@ -0,0 +1,2 @@ +#Sun Oct 22 16:39:19 MSK 2023 +useImports= diff --git a/.dn/ide/project/behaviours/PhpProjectBehaviour.conf b/.dn/ide/project/behaviours/PhpProjectBehaviour.conf new file mode 100644 index 0000000..d9fd9f8 --- /dev/null +++ b/.dn/ide/project/behaviours/PhpProjectBehaviour.conf @@ -0,0 +1,2 @@ +#Sun Oct 22 16:39:19 MSK 2023 +importType=package diff --git a/.dn/library.conf b/.dn/library.conf new file mode 100644 index 0000000..c349674 --- /dev/null +++ b/.dn/library.conf @@ -0,0 +1 @@ +#Sun Oct 22 16:39:19 MSK 2023 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bec9f52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Ignore rules for GIT (github.com, bitbucket.com, etc.) + +/.dn/cache +/.dn/ide.lock +/.dn/tmp +/.dn/index.json +/.dn/backup + +/vendor +/src_generated +/src/JPHP-INF +/src/.debug +/build +/build.xml +/build.gradle +/settings.gradle + +*.log +*.pid +*.tmp +*.sourcemap \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7cdaaa4 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# jutsu-dl + JutSu video downloader diff --git a/jutsu-dl.dnproject b/jutsu-dl.dnproject new file mode 100644 index 0000000..a2d4cb5 --- /dev/null +++ b/jutsu-dl.dnproject @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/.system/application.conf b/src/.system/application.conf new file mode 100644 index 0000000..9ce7018 --- /dev/null +++ b/src/.system/application.conf @@ -0,0 +1,12 @@ +# MAIN CONFIGURATION + +app.name = jutsu-dl +app.uuid = 852ff70c-d3fe-4758-977f-299a2f73436d +app.version = 1 + +# APP +app.namespace = app +app.mainForm = +app.showMainForm = 1 + +app.fx.splash.autoHide = 0 \ No newline at end of file diff --git a/src/.theme/style.fx.css b/src/.theme/style.fx.css new file mode 100644 index 0000000..170ef8a --- /dev/null +++ b/src/.theme/style.fx.css @@ -0,0 +1,2 @@ +/* JavaFX CSS Style with -fx- prefix */ + diff --git a/src/app/forms/MainForm.behaviour b/src/app/forms/MainForm.behaviour new file mode 100644 index 0000000..6ca4280 --- /dev/null +++ b/src/app/forms/MainForm.behaviour @@ -0,0 +1,2 @@ + + diff --git a/src/app/forms/MainForm.conf b/src/app/forms/MainForm.conf new file mode 100644 index 0000000..b533eb7 --- /dev/null +++ b/src/app/forms/MainForm.conf @@ -0,0 +1,4 @@ +#Fri Oct 20 13:49:07 MSK 2023 +form.style=DECORATED +modules= +title=MainForm diff --git a/src/app/forms/MainForm.fxml b/src/app/forms/MainForm.fxml new file mode 100644 index 0000000..baa4c96 --- /dev/null +++ b/src/app/forms/MainForm.fxml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/app/forms/MainForm.php b/src/app/forms/MainForm.php new file mode 100644 index 0000000..be374a8 --- /dev/null +++ b/src/app/forms/MainForm.php @@ -0,0 +1,10 @@ + + diff --git a/src/app/modules/AppModule.behaviour b/src/app/modules/AppModule.behaviour new file mode 100644 index 0000000..6ca4280 --- /dev/null +++ b/src/app/modules/AppModule.behaviour @@ -0,0 +1,2 @@ + + diff --git a/src/app/modules/AppModule.module b/src/app/modules/AppModule.module new file mode 100644 index 0000000..4f4063f --- /dev/null +++ b/src/app/modules/AppModule.module @@ -0,0 +1,13 @@ +{ + "props": [], + "components": { + "downloader": { + "type": "bundle\\http\\HttpDownloader", + "x": 496, + "y": 288, + "props": { + "threadCount": "4" + } + } + } +} \ No newline at end of file diff --git a/src/app/modules/AppModule.php b/src/app/modules/AppModule.php new file mode 100644 index 0000000..17ce6e4 --- /dev/null +++ b/src/app/modules/AppModule.php @@ -0,0 +1,120 @@ +form('MainForm')->browser->engine->url = $GLOBALS['argv'][1]; + + Logger::info('Waiting for the player to load to get the video URL'); + $this->timer['timeout'] = Timer::after('25s',function (){self::exitWithError('Timeout');}); + $this->timer['getUrl'] = Timer::every(200,[$this,'getUrl']); + } + + function getUrl() + { + uiLater(function () + { + try + { + $element = app()->form('MainForm')->browser->engine->document->getElementById('my-player_html5_api'); + $url = app()->form('MainForm')->browser->engine->document->getElementById('my-player_html5_api')->getAttribute('src'); + } + catch (Throwable $ex){return;} + + if ($element != null and $url != '1' and $url != null) + { + $this->timer['timeout']->cancel(); + $this->timer['getUrl']->cancel(); + + $this->download($url); + } + }); + } + + function download($url) + { + new Thread(function () use ($url) + { + if ($GLOBALS['argv'][2] != null and fs::isDir($GLOBALS['argv'][2])) + { + if (File::of($GLOBALS['argv'][2])->canWrite() == false) + self::exitWithError('No rights to write to this directory'); + + $path = $GLOBALS['argv'][2]; + } + elseif ($GLOBALS['argv'][2] == null) + { + $path = fs::abs('./'); + Logger::warn('The download path is not specified, working directory is used'); + } + elseif (fs::isDir($GLOBALS['argv'][2]) == false) + self::exitWithError('Destination directory not found'); + + Logger::info('Video URL - '.$url); + Logger::info('Path for downloading - '.$path); + + $videoname = str::sub($url,str::lastPos($url,'/'),str::lastPos($url,'.mp4')).'.mp4'; + + if (fs::isFile($path.'/'.$videoname)) + { + Logger::warn('File already exists, skipping download'); + Logger::info('OK - '.$path.'/'.$videoname); + + System::halt(0); + } + else + { + $downloader = new HttpDownloader; + $downloader->client()->userAgent = app()->form('MainForm')->browser->engine->userAgent; + $downloader->useTempFile = true; + $downloader->destDirectory = $path; + $downloader->urls = [$url]; + + $downloader->on('successOne',function () use ($path,$videoname) + { + Logger::info('Downloaded'); + Logger::info('OK - '.$path.'/'.$videoname); + + System::halt(0); + }); + $downloader->on('errorOne',function () + { + self::exitWithError('Some error was occurred when downloading video'); + }); + + $downloader->start(); + } + })->start(); + } + + static function exitWithError($message) + { + Logger::error($message); + System::halt(1); + } +} diff --git a/src/app/modules/AppModule.php.axml b/src/app/modules/AppModule.php.axml new file mode 100644 index 0000000..09d2741 --- /dev/null +++ b/src/app/modules/AppModule.php.axml @@ -0,0 +1,4 @@ + + + +