Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzEdovec committed Oct 22, 2023
0 parents commit 5b0faaf
Show file tree
Hide file tree
Showing 25 changed files with 262 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dn/backup.conf
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .dn/bundles/develnext.bundle.httpclient.HttpClientBundle.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Sun Oct 22 16:39:19 MSK 2023
version=1.0
name=HTTP Client
env=all
2 changes: 2 additions & 0 deletions .dn/bundles/ide.bundle.std.JPHPDesktopDebugBundle.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sun Oct 22 16:39:19 MSK 2023
env=dev
2 changes: 2 additions & 0 deletions .dn/bundles/ide.bundle.std.UIDesktopBundle.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sun Oct 22 16:39:19 MSK 2023
env=all
6 changes: 6 additions & 0 deletions .dn/ide/editors/FormEditor/src/app/forms/MainForm.php.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Fri Oct 20 15:20:53 MSK 2023
snapType=DOTS
blockedNodes=
zoom=100
snapSizeY=8
snapSizeX=8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sun Oct 22 16:39:19 MSK 2023
blockedNodes=
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Fri Oct 20 00:10:52 MSK 2023
blockedNodes=
2 changes: 2 additions & 0 deletions .dn/ide/project/behaviours/BundleProjectBehaviour.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sun Oct 22 16:39:19 MSK 2023
useImports=
2 changes: 2 additions & 0 deletions .dn/ide/project/behaviours/PhpProjectBehaviour.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sun Oct 22 16:39:19 MSK 2023
importType=package
1 change: 1 addition & 0 deletions .dn/library.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Sun Oct 22 16:39:19 MSK 2023
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# jutsu-dl
JutSu video downloader
28 changes: 28 additions & 0 deletions jutsu-dl.dnproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project author="zzedo" authorOS="Windows 11" createdAt="1697744159518" ideName="DevelNext" ideVersion="16.7.0" ideVersionHash="2017103112" name="jutsu-dl" packageName="app" template="ide\project\templates\DefaultGuiProjectTemplate" updatedAt="1697981959570">
<tree>
<expanded>
<path src=""/>
<path src="/src"/>
<path src="/src/.theme"/>
<path src="/src/app"/>
<path src="/src/app/forms"/>
<path src="/src/app/modules"/>
</expanded>
</tree>
<openedFiles>
<file src="jutsu-dl.dnproject"/>
<file selected="1" src="src/app/modules/AppModule.php"/>
</openedFiles>
<files/>
<behaviours>
<behaviour class="ide\project\behaviours\BundleProjectBehaviour"/>
<behaviour class="ide\project\behaviours\PhpProjectBehaviour"/>
<behaviour class="ide\project\behaviours\JavaPlatformBehaviour"/>
<behaviour class="ide\project\behaviours\GuiFrameworkProjectBehaviour"/>
<behaviour class="ide\project\behaviours\RunBuildProjectBehaviour"/>
<behaviour class="ide\project\behaviours\ShareProjectBehaviour"/>
<behaviour class="ide\project\behaviours\BackupProjectBehaviour"/>
<behaviour class="ide\project\behaviours\GradleProjectBehaviour"/>
</behaviours>
</project>
12 changes: 12 additions & 0 deletions src/.system/application.conf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/.theme/style.fx.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* JavaFX CSS Style with -fx- prefix */

2 changes: 2 additions & 0 deletions src/app/forms/MainForm.behaviour
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<behaviours/>
4 changes: 4 additions & 0 deletions src/app/forms/MainForm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Fri Oct 20 13:49:07 MSK 2023
form.style=DECORATED
modules=
title=MainForm
7 changes: 7 additions & 0 deletions src/app/forms/MainForm.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?import javafx.scene.*?><?import javafx.collections.*?><?import javafx.scene.layout.*?><?import javafx.scene.control.*?><?import javafx.scene.text.*?><?import javafx.scene.image.*?><?import javafx.scene.shape.*?><?import javafx.scene.paint.*?><?import javafx.scene.web.*?><?import javafx.geometry.*?><?import java.lang.*?><?import org.develnext.jphp.ext.javafx.classes.data.*?><?import org.develnext.jphp.ext.javafx.support.*?><?import org.develnext.jphp.ext.javafx.support.control.*?><?import org.develnext.jphp.ext.game.support.*?><AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" focusTraversable="false" id="" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480" prefWidth="640" styleClass="">
<children>
<WebView AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" focusTraversable="true" id="browser" layoutX="0" layoutY="0" prefHeight="480" prefWidth="640"/>
<Data cursor="DEFAULT" enabled="1" id="data-browser" visible="1"/>
</children>
</AnchorPane>
10 changes: 10 additions & 0 deletions src/app/forms/MainForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace app\forms;

use std, gui, framework, app;


class MainForm extends AbstractForm
{

}
2 changes: 2 additions & 0 deletions src/app/forms/MainForm.php.axml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root/>
2 changes: 2 additions & 0 deletions src/app/modules/AppModule.behaviour
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<behaviours/>
13 changes: 13 additions & 0 deletions src/app/modules/AppModule.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"props": [],
"components": {
"downloader": {
"type": "bundle\\http\\HttpDownloader",
"x": 496,
"y": 288,
"props": {
"threadCount": "4"
}
}
}
}
120 changes: 120 additions & 0 deletions src/app/modules/AppModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php
namespace app\modules;

use Throwable;
use httpclient;
use std, gui, framework, app;


class AppModule extends AbstractModule
{
$timer;

/**
* @event action
*/
function doAction(ScriptEvent $e = null)
{
if (isset($GLOBALS['argv'][1]) == false)
{
self::exitWithError('Link not specified');
return;
}
if (str::contains($GLOBALS['argv'][1],'episode-') == false
and str::contains($GLOBALS['argv'][1],'film-') == false
or str::contains($GLOBALS['argv'][1],'jut.su/') == false)
{
self::exitWithError('Invalid link');
return;
}

app()->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);
}
}
4 changes: 4 additions & 0 deletions src/app/modules/AppModule.php.axml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<class name="AppModule"/>
</root>

0 comments on commit 5b0faaf

Please sign in to comment.