Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
P
PlayBot
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Déploiement
Releases
Registre de modèles
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Loïc DEFRANCE
PlayBot
Validations
ed0e56ba
Valider
ed0e56ba
rédigé
9 years ago
par
Alexandre Morignot
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
prepare support for playlists
parent
2ac328d1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
PlayBot/sites.pm
+64
-18
64 ajouts, 18 suppressions
PlayBot/sites.pm
avec
64 ajouts
et
18 suppressions
PlayBot/sites.pm
+
64
−
18
Voir le fichier @
ed0e56ba
...
...
@@ -4,6 +4,7 @@ use strict;
use
warnings
;
use
Module::
Pluggable
sub_name
=>
'
sites
',
search_path
=>
['
PlayBot::sites
'],
require
=>
1
;
use
Storable
qw(dclone)
;
use
PlayBot::utils::
db
;
use
PlayBot::utils::db::
chan
;
...
...
@@ -31,10 +32,19 @@ sub parse {
{
not
grep
{
$site
eq
"
PlayBot::sites::
$_
"
}
@
{
$chan_conf
->
sites
}
and
next
;
if
(
my
@args
=
(
$msg
=~
$site
->
regex
))
my
@args
;
if
(
@args
=
(
$msg
=~
$site
->
regex
))
{
eval
{
%content
=
$site
->
get
(
@args
)
};
$matching_url
=
$&
;
$content
{
playlist
}
=
0
;
last
;
}
elsif
(
$site
->
can
('
regex_playlist
')
and
@args
=
(
$msg
=~
$site
->
regex_playlist
))
{
eval
{
%content
=
$site
->
get_playlist
(
@args
)
};
$matching_url
=
$&
;
$content
{
playlist
}
=
1
;
last
;
}
}
...
...
@@ -45,9 +55,20 @@ sub parse {
return
;
}
my
$id
;
# if we get a new content, we must save it
if
(
%content
)
{
@matching_tags
=
insert_content
(
$kernel
,
$nick
,
$chan
,
\
%content
,
$msg
);
(
$id
,
@matching_tags
)
=
insert_content
(
$kernel
,
$nick
,
$chan
,
dclone
(
\
%content
),
$msg
,
$playlist
);
if
(
not
$playlist
and
$content
{
playlist
})
{
foreach
my
$url
(
@
{
$content
{
urls
}
})
{
my
$new_msg
=
$msg
;
$new_msg
=~
s/\Q$matching_url\E/$url/
;
parse
(
$kernel
,
$user
,
$chan
,
$new_msg
,
$id
);
}
}
}
return
(
...
...
@@ -58,7 +79,7 @@ sub parse {
sub
insert_content
{
my
(
$kernel
,
$nick
,
$chan
,
$content
,
$msg
)
=
@_
;
my
(
$kernel
,
$nick
,
$chan
,
$content
,
$msg
,
$playlist
)
=
@_
;
my
$dbh
=
PlayBot::utils::db::
main_session
();
my
$id
;
...
...
@@ -68,8 +89,8 @@ sub insert_content
# insertion de la vidéo dans la bdd
eval
{
my
$sth
=
$dbh
->
prepare
('
INSERT INTO playbot (type, url, sender, title, duration)
VALUES (?,?,?,?,?)
INSERT INTO playbot (type, url, sender, title, duration
, playlist
)
VALUES (?,?,?,?,?
,?
)
');
$log
->
error
("
Couldn't prepare querie; aborting
")
unless
(
defined
$sth
);
...
...
@@ -78,7 +99,8 @@ sub insert_content
$content
->
{'
url
'},
$content
->
{'
author
'},
$content
->
{'
title
'},
$content
->
{'
duration
'}
$content
->
{'
duration
'},
$content
->
{'
playlist
'},
);
};
if
(
$@
)
{
...
...
@@ -111,18 +133,39 @@ sub insert_content
$id
=
$sth
->
fetch
->
[
0
];
# insertion du chan
$sth
=
$dbh
->
prepare
('
INSERT INTO playbot_chan (content, chan, sender_irc)
VALUES (?,?,?)
');
$log
->
error
("
Couldn't prepare querie; aborting
")
unless
(
defined
$sth
);
if
(
defined
(
$playlist
))
{
# save track in the playlist
$sth
=
$dbh
->
prepare
('
INSERT INTO playbot_playlist_content_association (playlist_id, content_id)
VALUES (?,?)
');
$log
->
error
("
Couldn't prepare querie; aborting
")
unless
(
defined
$sth
);
eval
{
$sth
->
execute
(
$playlist
,
$id
);
$dbh
->
commit
;
};
if
(
$@
)
{
# the association already exists
$dbh
->
rollback
;
}
}
else
{
# insertion du chan
$sth
=
$dbh
->
prepare
('
INSERT INTO playbot_chan (content, chan, sender_irc)
VALUES (?,?,?)
');
$log
->
error
("
Couldn't prepare querie; aborting
")
unless
(
defined
$sth
);
$sth
->
execute
(
$id
,
$chan
,
$nick
)
or
$log
->
error
("
Couldn't finish transaction:
"
.
$dbh
->
errstr
);
$sth
->
execute
(
$id
,
$chan
,
$nick
)
or
$log
->
error
("
Couldn't finish transaction:
"
.
$dbh
->
errstr
);
$dbh
->
commit
;
$dbh
->
commit
;
}
my
@matching_tags
=
PlayBot::commands::parser::
tag
(
$msg
,
$chan
);
my
@matching_tags
=
PlayBot::commands::parser::
tag
(
$msg
,
$chan
,
$id
);
my
@tags
;
# get tags
...
...
@@ -151,10 +194,13 @@ sub insert_content
$content
->
{'
tags
'}
=
\
@tags
;
delete
$content
->
{'
url
'};
# message sur irc
$irc
->
yield
(
privmsg
=>
$chan
=>
PlayBot::utils::print::
print
(
$content
));
if
(
not
$playlist
)
{
# message sur irc
$irc
->
yield
(
privmsg
=>
$chan
=>
PlayBot::utils::print::
print
(
$content
));
}
return
@matching_tags
;
return
$content
->
{
id
},
@matching_tags
;
}
1
;
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter