Lokaltog/powerline — pull request #968 by mreinhardt (2014-08-07 20:09:13+00:00)
Title: Fix NowPlaying segment when comma in title/track

With this theme configuration:

```json
{
"name": "now_playing",
"align": "r",
"args": {
"player": "spotify_apple_script",
"format": "{artist} - {title}"
}
}
```

An error will occur when there are commas in the artist or title (e.g. below for title "Time, Patience, Everything"):

```sh
2014-08-07 11:55:45,798:ERROR:shell:now_playing:Exception while computing segment: invalid literal for int() with base 10: 'Patience'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Powerline-beta-py2.7.egg/powerline/theme.py", line 96, in get_segments
contents = segment['contents_func'](self.pl, segment_info)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Powerline-beta-py2.7.egg/powerline/segment.py", line 102, in
contents_func = lambda pl, segment_info: _contents_func(pl=pl, **args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Powerline-beta-py2.7.egg/powerline/segments/common.py", line 918, in __call__
func_stats = player_func(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Powerline-beta-py2.7.egg/powerline/segments/common.py", line 1081, in player_spotify_apple_script
'total': self._convert_seconds(int(spotify_status[4]))
ValueError: invalid literal for int() with base 10: 'Patience'
```

This commit fixes the issue by using a (very likely) unique delimiter to separate status fields.

It also moves the status length trimming to an optional call parameter. So to trim the now playing status to 40 characters max you would use the config:

```json
{
"name": "now_playing",
"align": "r",
"args": {
"player": "spotify_apple_script",
"format": "{artist} - {title}",
"trim": 40
}
}
```