02.07.2013 Views

article de presse - Cap Data Consulting

article de presse - Cap Data Consulting

article de presse - Cap Data Consulting

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

P ratique<br />

http://www.parisdjs.com/share/feeds/podcast.xml<br />

http://radiofrance-podcast.net/podcast/rss_18780.xml<br />

http://www.1001podcast.com/podcast/RMCInfo/channel44/RMCInfochann<br />

el44.xml<br />

http://rss.radio-canada.ca/revuetechno.xml<br />

http://1001podcast.com/podcast/BFM/channel22/BFMchannel22.xml<br />

http://www2.rtl.fr/fournisseurs/podcasting/podcast_RTL_Fogiel.xml<br />

La <strong>de</strong>rnière ligne <strong>de</strong> ce fichier bp.conf doit contenir un retour <strong>de</strong> chariot.<br />

Les fichiers audio sont rapatriés à l'ai<strong>de</strong> <strong>de</strong> la comman<strong>de</strong> wget, et<br />

une liste <strong>de</strong> ceux-ci est créée qui s'ajoutera à une éventuelle liste existante<br />

(la comman<strong>de</strong> « sort » la triera).<br />

while read podcast<br />

do<br />

file=$(wget -q $podcast -O - | xsltproc parse_enclosure.xsl - 2><br />

/<strong>de</strong>v/null) || file=$(wget -q $podcast -O - | tr '\r' '\n' | tr \'<br />

\" | sed -n 's/.*url="\([^"]*\)".*/\1/p')<br />

for url in $file<br />

do<br />

if ! grep "$url" podcast.log > /<strong>de</strong>v/null<br />

then<br />

wget -q -P $datadir "$url" && echo $url >> temp.log<br />

fi<br />

done<br />

done < bp.conf<br />

cat podcast.log >> temp.log<br />

sort temp.log | uniq > podcast.log<br />

rm temp.log<br />

Enfin, <strong>de</strong>rnière étape, nous créons une playlist m3u (lisible par winapp, etc.) :<br />

ls $datadir | grep -v m3u > $datadir/podcast.m3u<br />

En résumé, premièrement, vous <strong>de</strong>vez créer un fichier podcasting.sh (le<br />

script) et lui attribuer les droits d'exécution (chmod +x podcasting.sh),<br />

<strong>de</strong>uxièmement, vous <strong>de</strong>vez créer un fichier podcast.log vi<strong>de</strong> (touch<br />

podcast.log), et troisièmement, garnir le fichier bp.conf <strong>de</strong>s fils RSS<br />

choisis (en terminant la liste par un retour <strong>de</strong> chariot).<br />

Lecture et création <strong>de</strong> Flux RSS en C#<br />

et VB.NET avec RSS.NET<br />

Avec .net, il est possible <strong>de</strong> sérialiser / désérialiser le flux XML pour créer<br />

ou lire le flux XML ; comme ici en VB.NET :<br />

im item As New Tekigo.Blog.RSSItem<br />

item.Description = "Contenu du message"<br />

item.Title = "Titre du message"<br />

Dim xmlSer As System.Xml.Serialization.XmlSerializer<br />

xmlSer = New System.Xml.Serialization.XmlSerializer(<br />

GetType(Tekigo.Blog.RSSItem) )<br />

Dim sw As System.IO.StringWriter = New<br />

System.IO.StringWriter<br />

xmlSer.Serialize(sw, item)<br />

Dim itemEnXml As String = sw.ToString()<br />

Mais il y a plus simple... Nous allons utiliser la bibliothèque RSS.NET pour<br />

lire ou créer un flux RSS en C# ou VB.NET. Elle fonctionne aussi bien sous<br />

Windows que sous Linux avec Mono. Après avoir récupéré le <strong>de</strong>rnier snapshot<br />

RSS.NET.tar.gz, et décompressé celui-ci, vous pouvez effectuer la compilation<br />

à l'ai<strong>de</strong> d'un simple make, ce qui aura pour effet <strong>de</strong> lancer le compilateur<br />

Mono :<br />

home/xl/RSS.NET # make<br />

mcs /target:library RssFeed.cs RssModule.cs RssModuleItem.cs<br />

RssRea<strong>de</strong>r.cs RssWriter.cs Collections/ExceptionCollection.cs<br />

Collections/RssCategoryCollection.cs<br />

Collections/RssChannelCollection.cs Collections/RssFeedCollection.cs<br />

Collections/RssItemCollection.cs Collections/RssModuleCollection.cs<br />

Collections/RssModuleItemCollection.cs<br />

Collections/RssModuleItemCollectionCollection.cs<br />

RssChannel/RssChannel.cs RssChannel/RssCloud.cs<br />

RssChannel/RssImage.cs RssChannel/RssTextInput.cs<br />

RssItem/RssEnclosure.cs RssItem/RssGuid.cs RssItem/RssItem.cs<br />

RssItem/RssSource.cs RssModules/RssPhotoAlbum.cs Shared/DBBool.cs<br />

Shared/RssCategory.cs Shared/RssDefault.cs Shared/RssElement.cs<br />

Shared/RssEnumerators.cs -o RSS.NET.dll<br />

Au final, la dll « RSS.NET.dll » est générée (avec la version 1.1.8.0 <strong>de</strong><br />

Mono). Vous pouvez maintenant utiliser cette dll en indiquant using Rss;<br />

en début <strong>de</strong> vos co<strong>de</strong>s sources. La lecture d'un fil s'effectue avec la<br />

métho<strong>de</strong> Read() ce qui donne en C# :<br />

string url = "http://sourceforge.net/export/rss2_sfnews.php?feed";<br />

RssFeed feed = RssFeed.Read(url);<br />

et en VB.NET :<br />

Programmez n°85 70 avril 2006<br />

Dim url As String =<br />

"http://sourceforge.net/export/rss2_sfnews.php?feed"<br />

Dim feed As RssFeed = RssFeed.Read(url)<br />

Vous pouvez aussi créer un fil RSS (mais pour que cela fonctionne vous<br />

<strong>de</strong>vez d'abord créer un jeu d'enregistrements avec <strong>de</strong>s canaux et <strong>de</strong>s<br />

items pour chaque canal). Ce qui donne en C# :<br />

RssFeed feed = new RssFeed();<br />

feed.Channels.Add(channel);<br />

Response.ContentType = "text/xml";<br />

feed.Write(Response.OutputStream);<br />

Response.End();<br />

et en VB.NET :<br />

Dim feed As New RssFeed<br />

feed.Channels.Add(channel)<br />

Niveau<br />

XML facile avancé expert

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!