-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Rpsl/7-preserve-sorting-of-queue
#7 Preserve sorting of queue
- Loading branch information
Showing
5 changed files
with
233 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
# soap4.me downloader | ||
# Soap4.me downloader | ||
|
||
**Для работы необходим премиум аккаунт** | ||
|
||
Это форкнутый и переписанный, на скорую руку, скрипт [TurboLoader](https://github.com/Rpsl/turboload), который, как можно догадаться из названия, автоматически скачивает сериалы с сервиса [soap4.me](http://soap4.me) | ||
|
||
## Зачем? | ||
|
||
Мне удобно когда все серии скачиваются на сетевой хранилище | ||
|
@@ -32,14 +30,25 @@ SOAP_PASSWORD="" | |
NOTIFY_EMAIL="[email protected]" | ||
MAILGUN_DOMAIN="domain.mailgun.org" | ||
MAILGUN_FROM="Turboloader <turboload@domain.mailgun.org>" | ||
MAILGUN_FROM="Soap4me downloader <soap4me@domain.mailgun.org>" | ||
MAILGUN_KEY="" | ||
``` | ||
|
||
|
||
### Docker | ||
# Docker | ||
|
||
Build image from sources | ||
```bash | ||
$ docker build -t soap4me:latest . | ||
``` | ||
|
||
Pull image from github | ||
```bash | ||
docker pull docker.pkg.github.com/rpsl/soap4me/soap4me:latest | ||
``` | ||
|
||
|
||
Run downloader (not daemon mode) | ||
```bash | ||
docker build -t soap4me:latest . | ||
docker run --rm -it --name soap4me -v $(pwd)/downloads:/app/downloads/ -v $(pwd)/.env:/app/.env -v $(pwd)/cookie.json:/app/cookie.json soap4me:latest | ||
$ docker run --rm -it --name soap4me -v $(pwd)/downloads:/app/downloads/ -v $(pwd)/.env:/app/.env -v $(pwd)/cookie.json:/app/cookie.json soap4me:latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tests\Soap4me; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Psr\Log\AbstractLogger; | ||
use Soap4me\Downloader; | ||
use Soap4me\DownloaderTransport\AbstractTransport; | ||
use Soap4me\Episode; | ||
|
||
class DownloaderTest extends TestCase | ||
{ | ||
/** @var \PHPUnit\Framework\MockObject\MockObject|Downloader|Downloader */ | ||
private $downloader; | ||
|
||
private $queue; | ||
|
||
protected function setUp(): void | ||
{ | ||
/** | ||
* @var AbstractLogger $logger | ||
*/ | ||
$logger = $this->getMockBuilder(AbstractLogger::class) | ||
->disableOriginalConstructor() | ||
->getMockForAbstractClass(); | ||
|
||
/** | ||
* @var AbstractTransport $transport | ||
*/ | ||
$transport = $this->getMockBuilder(AbstractTransport::class) | ||
->disableOriginalConstructor() | ||
->getMockForAbstractClass(); | ||
|
||
$this->downloader = new Downloader($logger, $transport); | ||
|
||
$this->queue = null; | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
$this->queue = null; | ||
} | ||
|
||
public function testAdd() | ||
{ | ||
$episode = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
1, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$this->downloader->add($episode); | ||
|
||
$queue = $this->downloader->getQueue(); | ||
|
||
$this->assertSame( | ||
1, | ||
count($queue) | ||
); | ||
} | ||
|
||
public function testAddBatch() | ||
{ | ||
$episodes = []; | ||
|
||
$episodes[] = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
1, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$episodes[] = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
2, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$episodes[] = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
3, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$this->downloader->addBatch($episodes); | ||
|
||
$queue = $this->downloader->getQueue(); | ||
|
||
$this->assertSame( | ||
3, | ||
count($queue) | ||
); | ||
} | ||
|
||
public function testFilter_Sorting() | ||
{ | ||
$episodes = []; | ||
|
||
$episodes[] = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
4, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$episodes[] = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
2, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$episodes[] = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
3, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$episodes[] = new Episode( | ||
'The Simpsons', | ||
'The Winter of Our Monetized Content', | ||
31, | ||
1, | ||
'fullHD', | ||
'ru', | ||
'some-hash-string', | ||
12345, | ||
6789, | ||
'token-poken' | ||
); | ||
|
||
$this->downloader->addBatch($episodes); | ||
|
||
$queue = $this->downloader->getQueue(); | ||
|
||
$var = 1; | ||
|
||
foreach ($queue as $ep) { | ||
$this->assertSame($var, $ep->getNumber()); | ||
$var++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters