From f64ff5b03ccef1395ae2d6a50eb2106dccf5f2b0 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 16 Apr 2009 14:24:46 +0000 Subject: [PATCH] finally fix some bad utf-8 encodings and update infos --- INSTALL | 7 ++++--- README | 15 ++++++++++++--- deefuzz.py | 25 +++++++++++++++---------- tools/PyRSS2Gen.py | 4 ++-- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/INSTALL b/INSTALL index 929c18c..ff1e078 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2007-2007 Guillaume Pellerin +# Copyright (c) 2007-2009 Guillaume Pellerin # All rights reserved. # # This software is licensed as described in the file COPYING, which @@ -9,8 +9,9 @@ # # Author: Guillaume Pellerin - depends : python, python-dev, python-xml, python-shout | shout-python, libshout3, libshout3-dev, icecast2 - recommends : python-mutagen + depends : python, python-dev, python-xml, python-shout | shout-python, libshout3, + libshout3-dev, icecast2 python-mutagen + provides : shout-python python-shout is included in DeeFuzz but needs to be compiled and installed. diff --git a/README b/README index 3c2fc85..cb8e023 100644 --- a/README +++ b/README @@ -7,11 +7,20 @@ deefuzz : an easy and light media streaming tool # 1. Introduction # =============== -DeeFuzz is a light python program that streams media data from file systems to icecast2 -with the metadata. It supports MP3, OGG, SPEEX and THEORA media. +DeeFuzz Tools are new light and easy tools to stream audio and video over internet. It is dedicated to people who wants to create playlisted webradios or webTVs with rich media contents. It depends on python, icecast2 server, libshout and some other tools. + +Here are the main features of the DeeFuzz Tools: + + * MP3 and OGG (audio & video) streaming over internet + * Full metadata encapsulation and management + * RSS podcast feeding (current tracks and playlists) + * M3U playlist feefing + * Multi-theading architecture (multiple stations now authorized) + * Optional random (shuffled) playlists + * VERY light and optimized streaming process ! It is neccessary to provide a config file which sets all needed parameters -(see example/myfuzz.xml for example). +(see example/myfuzz.xml for an example). # 2. Installation diff --git a/deefuzz.py b/deefuzz.py index 4c2365f..219a6fe 100755 --- a/deefuzz.py +++ b/deefuzz.py @@ -237,8 +237,11 @@ class Station(Thread): else: sub_title = '(playlist)' + channel_subtitle = self.channel.name + ' ' + sub_title + for media in media_list: - media_link = self.channel.url + self.media_url_dir + media.file_name.decode() + media_link = self.channel.url + self.media_url_dir + media.file_name + media_link = media_link.decode('utf-8') media_description = '' for key in media.metadata.keys(): if media.metadata[key] != '': @@ -248,17 +251,19 @@ class Station(Thread): media_stats = os.stat(media.media) media_date = time.localtime(media_stats[8]) media_date = time.strftime("%a, %d %b %Y %H:%M:%S +0000", media_date) - + date_now = str(datetime.datetime.now()) + title = media.metadata['title'] artist = media.metadata['artist'] if not (title or artist): song = str(media.file_name) else: song = artist + ' : ' + title - + + if self.rss_enclosure == '1': rss_item_list.append(PyRSS2Gen.RSSItem( - title = song.decode(), + title = song, link = media_link, description = media_description, enclosure = PyRSS2Gen.Enclosure(media_link, str(media.size), 'audio/mpeg'), @@ -267,20 +272,20 @@ class Station(Thread): ) else: rss_item_list.append(PyRSS2Gen.RSSItem( - title = song.decode(), + title = song, link = media_link, description = media_description, guid = PyRSS2Gen.Guid(media_link), pubDate = media_date,) ) - rss = PyRSS2Gen.RSS2(title = self.channel.name + ' ' + sub_title, + rss = PyRSS2Gen.RSS2(title = channel_subtitle, link = self.channel.url, description = self.channel.description, - lastBuildDate = datetime.datetime.now(), + lastBuildDate = date_now, items = rss_item_list,) f = open(rss_file, 'w') - rss.write_xml(f) + rss.write_xml(f, 'utf-8') f.close() def set_playlist(self): @@ -387,9 +392,9 @@ class Station(Thread): if not (title or artist): song = str(self.current_media_obj[0].file_name) else: - song = str(artist) + ' : ' + str(title) + song = artist + ' : ' + title.decode('utf-8') - self.channel.set_metadata({'song': song}) + self.channel.set_metadata({'song': str(song)}) self.update_rss(self.current_media_obj, self.rss_current_file) self.logger.write('DeeFuzzing this file on %s : id = %s, index = %s, name = %s' \ % (self.short_name, self.id, self.index_list[self.id], self.current_media_obj[0].file_name)) diff --git a/tools/PyRSS2Gen.py b/tools/PyRSS2Gen.py index fc1f1cf..5a1975e 100644 --- a/tools/PyRSS2Gen.py +++ b/tools/PyRSS2Gen.py @@ -10,14 +10,14 @@ import datetime # Could make this the base class; will need to add 'publish' class WriteXmlMixin: - def write_xml(self, outfile, encoding = "iso-8859-1"): + def write_xml(self, outfile, encoding = "utf-8"): from xml.sax import saxutils handler = saxutils.XMLGenerator(outfile, encoding) handler.startDocument() self.publish(handler) handler.endDocument() - def to_xml(self, encoding = "iso-8859-1"): + def to_xml(self, encoding = "utf-8"): try: import cStringIO as StringIO except ImportError: -- 2.39.5