Changeset 0654705e9cebf971ac00e733c920e9548ae3adcd
- Timestamp:
- 12/16/10 01:24:03 (2 years ago)
- Author:
- Guillaume Pellerin <yomguy@…>
- Children:
- 7728f7fb84077743867feb0e8c5e30fb1240fd25
- Parents:
- 4334dd720924e001899883b2e290849dc6d9f68d
- git-committer:
- Guillaume Pellerin <yomguy@parisson.com> / 2010-12-16T00:24:03Z+0000
- Message:
-
add new twitter oauth methods, update doc
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rbed0735
|
r0654705
|
|
| 1 | 1 | # -*- coding: utf-8 -*- |
| 2 | 2 | # |
| 3 | | # Copyright (c) 2007-2009 Guillaume Pellerin <pellerin@parisson.com> |
| | 3 | # Copyright (c) 2007-2010 Guillaume Pellerin <pellerin@parisson.com> |
| 4 | 4 | # All rights reserved. |
| 5 | 5 | # |
| … |
… |
|
| 10 | 10 | # Author: Guillaume Pellerin <pellerin@parisson.com> |
| 11 | 11 | |
| 12 | | depends: python, python-dev, python-xml, python-shout | shout-python, libshout3, |
| | 12 | |
| | 13 | Dependencies |
| | 14 | ============= |
| | 15 | |
| | 16 | depends: python, python-dev, python-xml, python-shout | shout-python, libshout3, |
| 13 | 17 | libshout3-dev, python-mutagen |
| 14 | 18 | |
| 15 | | provides: shout-python |
| | 19 | provides: shout-python | python-shout, python-tinyurl |
| 16 | 20 | |
| 17 | | optional: python-twitter, python-tinyurl, python-liblo | pyliblo (>= 0.26) |
| | 21 | optional: python-twitter, python-liblo | pyliblo (>= 0.26) |
| 18 | 22 | |
| 19 | | recommends: icecast2 |
| | 23 | recommends: icecast2 |
| 20 | 24 | |
| 21 | | python-shout is included in the DeeFuzzer but needs to be compiled and installed |
| 22 | | if you don't install deefuzzer from its debian package with aptitude. |
| 23 | | As explained in shout-python/INSTALL, you just have to run this command : |
| 24 | 25 | |
| 25 | | $ cd shout-python |
| 26 | | $ sudo python setup.py install |
| | 26 | Install |
| | 27 | ========= |
| 27 | 28 | |
| 28 | | To install the DeeFuzzer (from the main deefuzzer directory) : |
| 29 | | |
| 30 | | $ sudo python install.py |
| | 29 | To install the DeeFuzzer, go to the main deefuzzer app directory, for example:: |
| | 30 | |
| | 31 | cd deefuzzer-0.4.3 |
| | 32 | |
| | 33 | and run the python installer:: |
| | 34 | |
| | 35 | sudo python install.py |
| 31 | 36 | |
| 32 | 37 | For more informations, see http://svn.parisson.org/deefuzzer/ |
| | 38 | |
| | 39 | |
| | 40 | Twitter (optional) |
| | 41 | ===================== |
| | 42 | |
| | 43 | To get track twitting, please install python-twitter, python-oauth2 and all their dependencies. |
| | 44 | As Twitter now requires oauth key system since 07/2010, you need to get your own access token key pair. |
| | 45 | Please run the dedicated script to do this:: |
| | 46 | |
| | 47 | python tools/get_access_token.py |
| | 48 | |
| | 49 | You will be invited to copy/paste an URL in your browser to get a pin code. |
| | 50 | Then copy/paste this code into the console and press ENTER. |
| | 51 | The script gives you a pair of keys : one access token key and one access token secret key. |
| | 52 | |
| | 53 | Change the <twitter> block options in your deefuzzer XML config file, giving the 2 keys. |
| | 54 | For example:: |
| | 55 | |
| | 56 | <twitter> |
| | 57 | <mode>1</mode> |
| | 58 | <key>85039615-H6yAtXXCx7NobF5W40FV0c8epGZsQGkE7MG6XRjD2</key> |
| | 59 | <secret>A1YW3llB9H9qVbjH8zOQTOkMlhVqh2a7LnA9Lt0b6Gc</secret> |
| | 60 | <tags>Music Groove</tags> |
| | 61 | </twitter> |
| | 62 | |
| | 63 | Your DeeFuzzer will now tweet the currently playing track and new tracks on your profile. |
| | 64 | |
| | 65 | |
| | 66 | OSC Control |
| | 67 | ============= |
| | 68 | |
| | 69 | Working, but no doc yet. Please read the code :) |
| | 70 | |
-
|
re922416
|
r0654705
|
|
| 50 | 50 | where CONFIGFILE is the path for a XML config file. For example:: |
| 51 | 51 | |
| 52 | | $ deefuzzer example/myfuzz.xml |
| | 52 | deefuzzer example/myfuzz.xml |
| 53 | 53 | |
| 54 | 54 | To make the deefuzzer act as a deamon, just play it in the background:: |
| 55 | 55 | |
| 56 | | $ deefuzzer example/myfuzz.xml & |
| | 56 | deefuzzer example/myfuzz.xml & |
| 57 | 57 | |
| 58 | 58 | Note that you must edit the config file with right parameters before playing. |
| … |
… |
|
| 67 | 67 | after a CTRL+Z, making this:: |
| 68 | 68 | |
| 69 | | $ kill -9 PROCESS_ID |
| | 69 | kill -9 PROCESS_ID |
| 70 | 70 | |
| 71 | 71 | or:: |
| 72 | 72 | |
| 73 | | $ kill -9 `pgrep deefuzzer` |
| | 73 | pkill -9 deefuzzer |
| 74 | 74 | |
| 75 | 75 | |
| … |
… |
|
| 90 | 90 | Next track:: |
| 91 | 91 | |
| 92 | | $ python tools/osc_next.py |
| | 92 | python tools/osc_next.py |
| 93 | 93 | |
| 94 | 94 | Start twitting:: |
| 95 | 95 | |
| 96 | | $ python tools/osc_twitter_start.py |
| | 96 | python tools/osc_twitter_start.py |
| 97 | 97 | |
| 98 | 98 | Stop twitting:: |
| 99 | 99 | |
| 100 | | $ python see tools/osc_twitter_stop.py |
| | 100 | python see tools/osc_twitter_stop.py |
| 101 | 101 | |
| 102 | 102 | Start relaying:: |
| 103 | 103 | |
| 104 | | $ python tools/osc_relay_start.py |
| | 104 | python tools/osc_relay_start.py |
| 105 | 105 | |
| 106 | 106 | Stop relaying:: |
| 107 | 107 | |
| 108 | | $ python see tools/osc_relay_stop.py |
| | 108 | python see tools/osc_relay_stop.py |
| 109 | 109 | |
| 110 | 110 | Start jingling:: |
| 111 | 111 | |
| 112 | | $ python see tools/osc_jingles_start.py |
| | 112 | python see tools/osc_jingles_start.py |
| 113 | 113 | |
| 114 | 114 | Stop jingling:: |
| 115 | 115 | |
| 116 | | $ python see tools/osc_jingles_stop.py |
| | 116 | python see tools/osc_jingles_stop.py |
| 117 | 117 | |
| 118 | 118 | |
-
|
r4334dd7
|
r0654705
|
|
| 46 | 46 | from tools import * |
| 47 | 47 | |
| 48 | | version = '0.4.3' |
| | 48 | version = '0.5.0' |
| 49 | 49 | year = datetime.datetime.now().strftime("%Y") |
| 50 | 50 | platform_system = platform.system() |
-
|
r348233e
|
r0654705
|
|
| 61 | 61 | <mode>0</mode> |
| 62 | 62 | <!-- Your twitter username --> |
| 63 | | <user>my_twitter_user</user> |
| | 63 | <key>your access token key</key> |
| 64 | 64 | <!-- Your twitter password --> |
| 65 | | <pass>my_twitter_password</pass> |
| | 65 | <secret>your access token secret key</secret> |
| 66 | 66 | <!-- These tags will be added to each twitter message --> |
| 67 | 67 | <tags>bla bla</tags> |
-
|
r3538089
|
r0654705
|
|
| 145 | 145 | if 'twitter' in self.station: |
| 146 | 146 | self.twitter_mode = int(self.station['twitter']['mode']) |
| 147 | | self.twitter_user = self.station['twitter']['user'] |
| 148 | | self.twitter_pass = self.station['twitter']['pass'] |
| | 147 | self.twitter_key = self.station['twitter']['key'] |
| | 148 | self.twitter_secret = self.station['twitter']['secret'] |
| 149 | 149 | self.twitter_tags = self.station['twitter']['tags'].split(' ') |
| 150 | 150 | if self.twitter_mode == 1: |
| … |
… |
|
| 213 | 213 | value = value[0] |
| 214 | 214 | import tinyurl |
| 215 | | self.twitter = Twitter(self.twitter_user, self.twitter_pass) |
| | 215 | self.twitter = Twitter(self.twitter_key, self.twitter_secret) |
| 216 | 216 | self.twitter_mode = value |
| 217 | 217 | message = "Received OSC message '%s' with arguments '%d'" % (path, value) |
| … |
… |
|
| 449 | 449 | #self.channel.set_metadata({'song': self.song, 'charset': 'utf8',}) |
| 450 | 450 | self.update_rss(self.current_media_obj, self.rss_current_file, '(currently playing)') |
| 451 | | self.logger.write_info('Deefuzzing on %s : id = %s, name = %s' \ |
| | 451 | self.logger.write_info('DeeFuzzing on %s : id = %s, name = %s' \ |
| 452 | 452 | % (self.short_name, self.id, self.current_media_obj[0].file_name)) |
| 453 | 453 | self.player.set_media(self.media) |
| … |
… |
|
| 460 | 460 | artist_names = self.artist.split(' ') |
| 461 | 461 | artist_tags = ' #'.join(list(set(artist_names)-set(['&', '-']))) |
| 462 | | message = '♫ %s %s on #%s #%s' % (self.prefix, self.song, self.short_name, artist_tags) |
| | 462 | message = '%s %s on #%s #%s' % (self.prefix, self.song, self.short_name, artist_tags) |
| 463 | 463 | tags = '#' + ' #'.join(self.twitter_tags) |
| 464 | 464 | message = message + ' ' + tags |
-
|
r7301ae6
|
r0654705
|
|
| 38 | 38 | |
| 39 | 39 | # Twitter DeeFuzzer keys |
| 40 | | TWITTER_CONSUMER_KEY = 'ozs9cPS2ci6eYQzzMSTb4g' |
| 41 | | TWITTER_CONSUMER_SECRET = '1kNEffHgGSXO2gMNTr8HRum5s2ofx3VQnJyfd0es' |
| | 40 | DEEFUZZER_CONSUMER_KEY = 'ozs9cPS2ci6eYQzzMSTb4g' |
| | 41 | DEEFUZZER_CONSUMER_SECRET = '1kNEffHgGSXO2gMNTr8HRum5s2ofx3VQnJyfd0es' |
| 42 | 42 | |
| 43 | 43 | |
| … |
… |
|
| 46 | 46 | def __init__(self, access_token_key, access_token_secret): |
| 47 | 47 | import twitter |
| 48 | | self.username = TWITTER_CONSUMER_KEY |
| 49 | | self.password = TWITTER_CONSUMER_SECRET |
| | 48 | self.consumer_key = DEEFUZZER_CONSUMER_KEY |
| | 49 | self.consumer_secret = DEEFUZZER_CONSUMER_SECRET |
| 50 | 50 | self.access_token_key = access_token_key |
| 51 | 51 | self.access_token_secret = access_token_secret |
| 52 | | self.api = twitter.Api(username=self.username, |
| 53 | | password=self.password, |
| | 52 | self.api = twitter.Api(consumer_key=self.consumer_key, |
| | 53 | consumer_secret=self.consumer_secret, |
| 54 | 54 | access_token_key=self.access_token_key, |
| 55 | 55 | access_token_secret=self.access_token_secret) |