Skip to content
Extraits de code Groupes Projets
Valider 9acf55f6 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

download content in tmp, then move

parent 4e8e15b2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -18,6 +18,7 @@ POE::Session->create( ...@@ -18,6 +18,7 @@ POE::Session->create(
filename => \&sessions::downloader::ddl::filename, filename => \&sessions::downloader::ddl::filename,
signal_filename => \&sessions::downloader::ddl::signal_filename, signal_filename => \&sessions::downloader::ddl::signal_filename,
signal_ddl => \&sessions::downloader::ddl::signal_ddl, signal_ddl => \&sessions::downloader::ddl::signal_ddl,
signal_move => \&sessions::downloader::ddl::signal_move,
end_task => \&sessions::downloader::ddl::end_task, end_task => \&sessions::downloader::ddl::end_task,
}, },
); );
......
...@@ -93,7 +93,7 @@ sub signal_filename { ...@@ -93,7 +93,7 @@ sub signal_filename {
"youtube-dl", "youtube-dl",
"--restrict-filename", "--restrict-filename",
"-o", "-o",
$conf->{save_folder}."/".$conf->{save_format}, "/tmp/".$conf->{save_format},
$heap->{ddl}->{pb}->{$id}->{url}, $heap->{ddl}->{pb}->{$id}->{url},
], ],
StdoutEvent => "devnull", StdoutEvent => "devnull",
...@@ -120,6 +120,40 @@ sub signal_ddl { ...@@ -120,6 +120,40 @@ sub signal_ddl {
if ($status ne "0") { if ($status ne "0") {
$log->error("error downloading $id : $status"); $log->error("error downloading $id : $status");
$kernel->yield("end_task");
}
# we actually download the content
$child = POE::Wheel::Run->new(
Program => [
"mv",
"/tmp/".$heap->{ddl}->{pb}->{$id}->{filename},
$conf->{save_folder}."/".$heap->{ddl}->{pb}->{$id}->{filename},
],
StdoutEvent => "devnull",
StderrEvent => "devnull",
);
$kernel->sig_child($child->PID, "signal_move");
# we link playbot id to PID and url
$heap->{ddl}->{pb}->{$id}->{child} = $child->PID;
# we link wheel id to playbot id
$heap->{ddl}->{wid}->{$child->ID} = $id;
# we link PID to child object
$heap->{ddl}->{pid}->{$child->PID} = $child;
}
sub signal_move {
$log->debug("DDL");
my ($kernel, $heap, $pid, $status) = @_[KERNEL, HEAP, ARG1, ARG2];
my $child = delete $heap->{ddl}->{pid}->{$pid};
my $id = delete $heap->{ddl}->{wid}->{$child->ID};
$heap->{ddl}->{pb}->{$id}->{child} = undef;
if ($status ne "0") {
$log->error("error moving $id from tmp : $status");
} }
else { else {
eval { eval {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter