Changeset 77f938108c38f31000cf130d4f5bef8e31adfb8a
- Timestamp:
- 12/14/09 01:41:22 (3 years ago)
- Author:
- Guillaume Pellerin <yomguy@…>
- Children:
- dbe9f5c4d1ea2d8af563d63bd8fb2fd9dd70862e
- Parents:
- 5277dfef6c190c796dab80dc046e6b48c00288ec
- git-committer:
- Guillaume Pellerin <yomguy@parisson.com> / 2009-12-14T00:41:22Z+0000
- Message:
-
add osc controller and next_media callback to skip current media
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5277dfe
|
r77f9381
|
|
| 47 | 47 | import subprocess |
| 48 | 48 | import platform |
| 49 | | import twitter |
| 50 | | import tinyurl |
| 51 | 49 | from threading import Thread |
| 52 | 50 | from tools import * |
| … |
… |
|
| 137 | 135 | self.stations = [] |
| 138 | 136 | self.logger.write('Number of stations : ' + str(self.nb_stations)) |
| 139 | | |
| 140 | | # Create M3U playlist |
| 141 | | self.logger.write('Writing M3U file to : ' + self.m3u) |
| 142 | 137 | |
| 143 | 138 | def get_conf_dict(self): |
| … |
… |
|
| 161 | 156 | i += 1 |
| 162 | 157 | m3u.close() |
| | 158 | self.logger.write('Writing M3U file to : ' + self.m3u) |
| | 159 | |
| 163 | 160 | |
| 164 | 161 | def run(self): |
| 165 | 162 | # Create a Queue |
| 166 | | # Not too much, otherwise, you will get memory leaks ! |
| 167 | 163 | q = Queue.Queue(1) |
| 168 | 164 | |
| … |
… |
|
| 274 | 270 | self.twitter = Twitter(self.twitter_user, self.twitter_pass) |
| 275 | 271 | self.twitter_tags = self.station['twitter']['tags'].split(' ') |
| | 272 | import tinyurl |
| 276 | 273 | self.tinyurl = tinyurl.create_one(self.channel.url + '/m3u/' + self.m3u.split(os.sep)[-1]) |
| 277 | 274 | |
| … |
… |
|
| 286 | 283 | self.jingle_id = 0 |
| 287 | 284 | |
| | 285 | self.osc_control = '0' |
| | 286 | if 'control' in self.station: |
| | 287 | self.osc_control_mode = self.station['control']['mode'] |
| | 288 | self.osc_port = self.station['control']['port'] |
| | 289 | if self.osc_control_mode =='1': |
| | 290 | self.osc_controller = OSCController(self.osc_port) |
| | 291 | self.osc_controller.add_method('/media/next', 'i', self.media_next_callback) |
| | 292 | self.osc_controller.start() |
| | 293 | |
| | 294 | def media_next_callback(self, path, value): |
| | 295 | value = value[0] |
| | 296 | self.osc_next_media = value |
| | 297 | message = "Received OSC message '%s' with arguments '%d'" % (path, value) |
| | 298 | self.logger.write(message) |
| | 299 | |
| 288 | 300 | def get_playlist(self): |
| 289 | 301 | file_list = [] |
| … |
… |
|
| 292 | 304 | s = file.split('.') |
| 293 | 305 | ext = s[len(s)-1] |
| 294 | | if ext.lower() == self.channel.format and not '/.' in file: |
| | 306 | if ext.lower() == self.channel.format and not os.sep+'.' in file: |
| 295 | 307 | file_list.append(root + os.sep + file) |
| 296 | 308 | file_list.sort() |
| … |
… |
|
| 303 | 315 | s = file.split('.') |
| 304 | 316 | ext = s[len(s)-1] |
| 305 | | if ext.lower() == self.channel.format and not '/.' in file: |
| | 317 | if ext.lower() == self.channel.format and not os.sep+'.' in file: |
| 306 | 318 | file_list.append(root + os.sep + file) |
| 307 | 319 | file_list.sort() |
| … |
… |
|
| 458 | 470 | break |
| 459 | 471 | media = self.get_next_media() |
| | 472 | self.osc_next_media = 0 |
| 460 | 473 | self.counter += 1 |
| 461 | 474 | q.task_done() |
| … |
… |
|
| 493 | 506 | self.channel.send(__chunk) |
| 494 | 507 | self.channel.sync() |
| | 508 | if self.osc_next_media != 0: |
| | 509 | break |
| 495 | 510 | # self.logger.write('Station delay (ms) ' + self.short_name + ' : ' + str(self.channel.delay())) |
| 496 | 511 | except: |
| … |
… |
|
| 554 | 569 | |
| 555 | 570 | def read_slow(self): |
| 556 | | """Read a bigger part of the media and stream the little parts of data through a generator |
| | 571 | """Read a bigger part of the media and stream the little parts of the data through a generator |
| 557 | 572 | """ |
| 558 | 573 | |
| … |
… |
|
| 579 | 594 | |
| 580 | 595 | class Twitter: |
| 581 | | """Post a message to Twitter""" |
| 582 | | |
| | 596 | |
| 583 | 597 | def __init__(self, username, password): |
| 584 | | #Thread.__init__(self) |
| | 598 | import twitter |
| 585 | 599 | self.username = username |
| 586 | 600 | self.password = password |
| … |
… |
|
| 592 | 606 | except: |
| 593 | 607 | pass |
| | 608 | |
| | 609 | |
| | 610 | class OSCController(Thread): |
| | 611 | |
| | 612 | def __init__(self, port): |
| | 613 | Thread.__init__(self) |
| | 614 | import liblo |
| | 615 | self.port = port |
| | 616 | try: |
| | 617 | self.server = liblo.Server(self.port) |
| | 618 | except liblo.ServerError, err: |
| | 619 | self.logger.write(str(err)) |
| | 620 | |
| | 621 | def add_method(self, path, type, method): |
| | 622 | self.server.add_method(path, type, method) |
| | 623 | |
| | 624 | def server(self): |
| | 625 | return self.server |
| | 626 | |
| | 627 | def run(self): |
| | 628 | while True: |
| | 629 | self.server.recv(1000) |
| 594 | 630 | |
| 595 | 631 | |
-
|
rb0f26c1
|
r77f9381
|
|
| 1 | 1 | <deefuzzer> |
| 2 | 2 | <log>/tmp/deefuzz.log</log> |
| 3 | | <m3u>/var/www/m3u/yomguy_playlist.m3u</m3u> |
| | 3 | <m3u>/var/www/m3u/mystation.m3u</m3u> |
| 4 | 4 | <station> |
| 5 | 5 | <infos> |
| … |
… |
|
| 40 | 40 | <shuffle>1</shuffle> |
| 41 | 41 | </jingles> |
| | 42 | <control> |
| | 43 | <mode>1</mode> |
| | 44 | <port>1234</port> |
| | 45 | </control> |
| 42 | 46 | </station> |
| 43 | 47 | </deefuzzer> |