Bonjour,

Je cherche à lire un stream en python.

Si le stream à lire sort d'un port d'un hôte, c'est très facile. Le code de la documentation Python suffit :
Code:
HOST = 'host.com'
PORT = 8000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
data = s.recv(1024)
s.close()
print 'Received', repr(data)
Maintenant, je cherche à lire un stream audio à partir d'un fichier (et pas simplement un hôte). L'URL complète est (par exemple) : http://streaming.rtbf.be:8000/pure128x8558

J'ai essayé ceci mais çà ne fonctionne pas :
Code:
import socket
INHOST = "streaming.rtbf.be"
INPORT = 8000
INPATH = "/pure128x8558"

inSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
inSock.connect((INHOST, INPORT))
# pour recevoir l'info à partir du fichier voulu en HTTP (marche pas ?) :
inSock.send("GET " + INPATH + "HTTP/1.0\r\nHost: " + INHOST + "\r\n\r\n")

i = 0
while i <= 10:
    data = inSock.recv(2048)
    if not data:
        print "no data, i = " + str(i)
        break
    print str(i) + ". Read ", len(data), " bytes"
    i = i + 1

inSock.close()
Je n'arrive qu'à recevoir aucune donnée. Est-ce que quelqu'un pourrait me dire ce qui ne va pas dans mon code ?

Un grand merci d'avance.