somadic 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd60324d1c5fe7d3a5c68e875726425dd502bfeb
4
- data.tar.gz: 01443ef9a424ca6ab52d99672b1b72413b977989
3
+ metadata.gz: ca4d0b5f1262c05f4c93871065843f3a08b16da5
4
+ data.tar.gz: dd8035445c3828512c2acfe0a80faf62e68020d7
5
5
  SHA512:
6
- metadata.gz: 10dcd6dc6e4ea32ef9b3f21292781c54be5f50918db340b6fd76c5b8c73e920c98dda4ce65f8ad666313c099dacff05e3784f0568290281fd0a8b6b28e354d5d
7
- data.tar.gz: 6de3b6f5669d335f936dabf10a4c28c7ec9f1ff1536777da20e8d6638a540ff9f08d24bce47e7fcc382807a4d10f33d94ace1827fa69e4e6946181941ac9ca35
6
+ metadata.gz: 824df614dc6f57756a05a79e1fc3e149e9e7ed78c14c2d852f81d1b517ebaac14e590b51f115a4b7d1715369df7b4316fa29b7bda4e7329e04d077196af75202
7
+ data.tar.gz: 3e1fb4eafd3569ed18942bc4c483041593209aa405df7c0da4cb6cae2f60452069515bf75b00a98f7f1bd59d43e44437ec105923b98dab15e3619ff830faf3c7
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Somadic
2
2
 
3
- Somadic is a bare-bones terminal-based player for somafm.com and di.fm. It uses `mplayer` to
4
- do the heavy lifting.
3
+ Somadic is a bare-bones terminal-based player for [somafm.com](http://somafm.com) and [di.fm](http://di.fm).
4
+ It uses `mplayer` to do the heavy lifting.
5
5
 
6
6
  ```
7
7
  $ somadic-curses di:breaks
@@ -17,17 +17,9 @@ $ somadic-curses di:breaks
17
17
 
18
18
  ## Installation
19
19
 
20
- Clone the repo:
21
-
22
- $ git clone https://github.com/devshane/somadic.git
23
-
24
- Build the gem:
25
-
26
- $ gem build somadic.gemspec
27
-
28
- Install the gem:
29
-
30
- $ gem install somadic-0.0.1.gem
20
+ ```
21
+ $ gem install somadic
22
+ ```
31
23
 
32
24
  ## Usage
33
25
 
@@ -58,6 +50,25 @@ s - Search Google for the current track
58
50
  / - Goto site:channel
59
51
  ```
60
52
 
53
+ #### Presets
54
+
55
+ You can create preset files rather than listing multiple channels on the command line. Create
56
+ a YAML file in `~/.somadic/presets`, say `chill.yaml`, with the following content:
57
+
58
+ ```
59
+ ---
60
+ - di:breaks
61
+ - soma:secretagent
62
+ - di:psychill
63
+ - soma:lush
64
+ ```
65
+
66
+ You can then start somadic with the preset's name:
67
+
68
+ ```
69
+ $ somadic chill
70
+ ```
71
+
61
72
  #### Examples
62
73
 
63
74
  **Listen to breaks on DI**
@@ -6,8 +6,8 @@ module Somadic
6
6
  end
7
7
 
8
8
  def refresh_playlist
9
- f = open(@url)
10
- page = f.read
9
+ page = open(@url).read
10
+ Somadic::Logger.debug("page=#{page}")
11
11
  data = JSON.parse(page[page.index("(") + 1..-3])
12
12
 
13
13
  symbolized_data = []
@@ -1,3 +1,5 @@
1
+ require 'pp'
2
+
1
3
  module Somadic
2
4
  module Channel
3
5
  class DI < Somadic::BaseChannel
@@ -14,9 +16,7 @@ module Somadic
14
16
  # Overrides BaseChannel
15
17
  def find_channel(name)
16
18
  Somadic::Logger.debug("DI#find_channel(#{name})")
17
- @channels.each do |c|
18
- return c if c[:name] == name
19
- end
19
+ @channels.each { |c| return c if c[:name] == name }
20
20
  nil
21
21
  end
22
22
 
@@ -24,6 +24,8 @@ module Somadic
24
24
  #
25
25
  # TODO: time isn't used, song isn't required
26
26
  def update(time, song)
27
+ return unless @channel
28
+
27
29
  @song = song if song
28
30
  aa = Somadic::AudioAddict.new(@channel[:id])
29
31
  songs = aa.refresh_playlist
@@ -66,16 +68,12 @@ module Somadic
66
68
  APICache.get('di_fm_channel_list', cache: ONE_DAY, timeout: API_TIMEOUT) do
67
69
  Somadic::Logger.debug('DI#load_channels')
68
70
  channels = []
69
- f = open('http://www.di.fm')
70
- page = f.read
71
- chan_ids = page.scan(/data-channel-id="(\d+)"/).flatten
72
- chans = page.scan(/data-tunein-url="http:\/\/www.di.fm\/(.*?)"/).flatten
73
- zipped = chan_ids.zip(chans)
74
- zipped.each do |z|
75
- channels << {id: z[0], name: z[1]}
76
- end
77
- channels.sort_by! {|k, _| k[:name]}
78
- channels.uniq! {|k, _| k[:name]}
71
+ page = open('http://www.di.fm').read
72
+ app_start = page.scan(/di\.app\.start\((.*?)\);/).flatten[0]
73
+ json = JSON.parse(app_start)
74
+ json['channels'].each { |c| channels << {id: c['id'], name: c['key']} }
75
+
76
+ channels
79
77
  end
80
78
  end
81
79
  end
@@ -1,3 +1,3 @@
1
1
  module Somadic
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: somadic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Thomas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2015-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mono_logger
@@ -218,3 +218,4 @@ test_files:
218
218
  - spec/lib/somadic/mplayer_spec.rb
219
219
  - spec/lib/somadic_spec.rb
220
220
  - spec/spec_helper.rb
221
+ has_rdoc: