Utilisateur:Delhovlyn/Allociné
Un article de Wikipédia, l'encyclopédie libre.
Remplace les liens vers Allociné en utilisant les modèles {{Allocine name}} ou {{Allocine title}}.
Buts :
- Uniformiser/Harmoniser
- Ajouter (automatiquement, par le modèle), l'attribut nopub=1 dans l'URL, ce qui permet de sauter la page de pub intersticielle visible à la première visite.
(type 1 seulement, pour l'instant)
Tools > Make Module. Cocher Enabled, C# 2.0 sélectionné, rentrer code, cliquer sur Make Module, puis sur Done si pas d'erreur. Ensuite, lancer en désactivant le Find and replace.
Sommaire |
[modifier] Films
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) { Regex title = new Regex (@"([^\(]+) \((films?|[0-9]{4}|films?, [0-9]{4}|(S|s)aga)\)"); Match myMatch = title.Match (ArticleTitle); String Title = myMatch.Groups[1].ToString (); String Title2 = "|title="+Title; if (Title == String.Empty) Title2 = ""; Regex film = new Regex(@"^\*\040?(\{\{[^\}]+\}\})?\040?('')?\[http://www\.allocine\.fr/film/fichefilm_gen_cfilm=([0-9]+)\.html?/? .*\].*"); ArticleText = film.Replace(ArticleText, "* {{Allocine title|id=$3"+Title2+"}}\r"); Skip = false; Summary = "Remplacement lien Allociné par modèle {{Allociné title}} — "; return ArticleText; }
[modifier] Personnes
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) { Regex title = new Regex (@"([^\(]+) \((acteur|actrice|réalisateur|réalisatrice)\)"); Match myMatch = title.Match (ArticleTitle); String Name = myMatch.Groups[1].ToString (); String Name2 = "|name="+Name; if (Name == String.Empty) Name2 = ""; Regex personne = new Regex(@"^\*\040?(\{\{[^\}]+\}\})?\040?('')?\[http://www\.allocine\.fr/personne/fichepersonne_gen_cpersonne=([0-9]+)\.html?/? .*\].*"); ArticleText = personne.Replace(ArticleText, "* {{Allocine name|id=$3"+Name2+"}}\r"); Skip = false; Summary = "Remplacement lien Allociné par modèle {{Allociné name}} — "; return ArticleText; }
[modifier] Films
1) Find → \*\s?(\{\{[^\}]+\}\})?\s?('')?\[http://www\.allocine\.fr/film/fichefilm_gen_cfilm=([0-9]+)\.html? .*\].* 2) Replace → * {{Allocine title|id=$3}}
[modifier] Personnes
1) Find → \*\s?(\{\{[^\}]+\}\})?\s?('')?\[http://www\.allocine\.fr/personne/fichepersonne_gen_cpersonne=([0-9]+)\.html? .*\].* 2) Replace → * {{Allocine name|id=$3}}
[modifier] La Règle (obsolète)
[modifier] Type 1
1) Find → http://www\.allocine\.(fr|com)/([a-z]+)/([a-z]+)_gen_c([a-z]+)=([0-9]+)\.html? 2) Replace → http://www.allocine.$1/$2/$3_gen_c$4=$5&nopub=1.html
[modifier] Type 2
1) Find → http://www\.allocine\.(fr|com)/([a-z]+)/([a-z]+)\.html?c([a-z]+)=([0-9]+) 2) Replace → http://www.allocine.$1/$2/$3.html?c$4=$5&nopub=1.html
[modifier] Général
[modifier] Type 1
http://www.allocine.fr/***/***_gen_c***=***.html → http://www.allocine.fr/***/***_gen_c***=***.html
[modifier] Type 2
http://www.allocine.fr/***/***.html?c***=*** → http://www.allocine.fr/***/***.html?c***=***