pifi 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb920bd37c323e567a17f4db4313dc01c20de16380626f8926649cb430728734
4
- data.tar.gz: 144f35f8044b2ab0ebe239bd3f8b94db798af965bd5835b8108782a0fb5a6e08
3
+ metadata.gz: b0b52109a7d2e0f8ce6fa62b9c87a13079966c6d9cdc4d88bdfb76245e3fad95
4
+ data.tar.gz: 7250d4469717c956e0fbb81d066fa3a12ac22f934d6cbfbcb69f74a769dde09c
5
5
  SHA512:
6
- metadata.gz: ee7e2b5ed2ad92d4d304735711b1c3261a93005615f34235ff387e54127fa25dcbf31b961fba114a37015ca7ce500201a3d31f468873ca16ccd9bb6f28f83061
7
- data.tar.gz: ea5afd4335fae44559323135da5d0756146371539aa9022334793dd5effd91324275b6e87b1d8179a15f74eb25129bb4510f8337dbf026848c5ec8f91212ae2e
6
+ metadata.gz: c03d08825762b9a79f93359aa42150a77dbc9d3f7133773bf3e2e974827413693ba47c304a8b78a9e050d1648aa45be98b62b623b70053b8b0ac375f51798f46
7
+ data.tar.gz: d851d8ba1e665ed37620f9ebee9c78d0dee371ebbf0ea80d6835f2e3b04b756ba4554d416ed6544c684e8d1a0c2044a8180a735589bcd282dc160d083b3a9275
data/INSTALL.md CHANGED
@@ -21,12 +21,10 @@ $ sudo systemctl start mpd && sudo systemctl enable mpd
21
21
  $ sudo gem install pifi --no-ri --no-rdoc
22
22
  ```
23
23
 
24
- 4. To run PiFi, you'll need a list of the radios you want to listen.
25
-
26
- Paste this for now:
24
+ 4. To run PiFi, you'll need a list of radios at `/etc/pifi_streams.json`. Paste this for now:
27
25
 
28
26
  ```
29
- sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/pifi_streams.json -O /etc/pifi_streams.json
27
+ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/pifi_streams.json.sample -O /etc/pifi_streams.json
30
28
  ```
31
29
 
32
30
  Later, you can edit that JSON file [as described here](README.md#list-of-streams).
@@ -42,22 +40,22 @@ $ sudo -e /etc/pifi.json
42
40
 
43
41
  **Done!** You can now run PiFi with `pifi` and reach it at `http://DEVICE_IP:3000`. Type `pifi -h` to check the options available.
44
42
 
45
- **Suggestion:** On your mobile browser, tap to add PiFi Radio to your home screen, for easier access.
46
-
47
43
  ## Running at system boot and as other user
48
44
 
49
- It makes sense to run PiFi as a less-privileged user (such as `www-data`). You may also want it to autostart on boot. If that's the case, follow these two steps.
45
+ It makes sense to run PiFi as a less-privileged user (such as `www-data`). You may also want it to autostart on boot. For that:
50
46
 
51
- 1. Download the systemd service and edit it to your needs.
47
+ 1. Download the systemd service.
52
48
 
53
49
  ```
54
50
  $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/pifi.service.sample -O /etc/systemd/system/pifi.service
55
- $ sudo -e /etc/systemd/system/pifi.service
56
51
  ```
57
52
 
58
- 2. Start and enable it:
53
+ 2. Make any changes relevant to your system.
54
+
55
+ For example, if you leave `User` and `Group` as they are (`www-data`), make sure that both exist in your system.
59
56
 
60
57
  ```
61
- $ sudo systemctl start pifi
62
- $ sudo systemctl enable pifi
58
+ $ sudo -e /etc/systemd/system/pifi.service
63
59
  ```
60
+
61
+ **Done!** Now you can start PiFi with `sudo systemctl start pifi`. For running at boot, enter `sudo systemctl enable pifi`.
data/README.md CHANGED
@@ -10,8 +10,8 @@ PiFi Radio: A MPD web client to listen to radio
10
10
  - [Demo](#demo)
11
11
  - [Installation](#installation)
12
12
  - [Configuration](#configuration)
13
- - [PiFi configuration](#pifi-configuration)
14
13
  - [List of streams](#list-of-streams)
14
+ - [PiFi configuration](#pifi-configuration)
15
15
  - [Credits](#credits)
16
16
  - [License](#license)
17
17
 
@@ -78,7 +78,7 @@ While PiFi was imagined for the Pi, it should run on any computer with:
78
78
 
79
79
  ### List of streams
80
80
 
81
- PiFi needs a list of the radios you want to listen. [A example is available here](docs/pifi_streams.json).
81
+ PiFi needs a list of the radios you want to listen. [A example is available here](docs/pifi_streams.json.sample).
82
82
 
83
83
  The list is read by default from `/etc/pifi_streams.json`. You can change this path [creating a configuration file](#pifi-configuration).
84
84
 
@@ -89,7 +89,7 @@ To keep it simple, the list of streams is just a JSON file with key-value pairs,
89
89
  "Radio 2": "https://example.com/radio"
90
90
  }
91
91
 
92
- If you want to arrange the stations in categories, add a pair with the category name as the key and empty value, as in:
92
+ If you want to arrange the stations in categories, add a pair with the category name as the key and empty value, as shown below. This will add the headers "Talk radio" and "Classical" above each group of stations, [such as "España" in the demo](#demo).
93
93
 
94
94
  {
95
95
  "Talk radio": "",
@@ -101,32 +101,40 @@ If you want to arrange the stations in categories, add a pair with the category
101
101
  "Radio 4": "https://example.com/radio4"
102
102
  }
103
103
 
104
- This will add the headers "Talk radio" and "Classical" above each group of stations, [such as "España" in the demo](#demo).
105
-
106
104
  ### PiFi configuration
107
105
 
108
106
  It's now completely optional to have a configuration file for PiFi. You only need one if you want something different from the defaults.
109
107
 
110
108
  The path is `/etc/pifi.json` and these are the options:
111
109
 
112
- | Key | Value |
113
- | --------------- | ----------------------------------------------------------------------------------------------------------------- |
114
- | `streams_file` | Path to the JSON file containing the streams. |
115
- | `mpd_host` | MPD host. |
116
- | `mpd_port` | MPD port. |
117
- | `mpd_password` | MPD password. |
118
- | `streamsp_file` | Path to JSON file containing additional streams. These will be shown only to the devices listed on `special_ips`. |
119
- | `special_ips` | The IPs of the devices to show additional streams. |
120
- | `play_local` | Set it to `true` if you want PiFi to play songs from your local library. This shows the "Random" button. |
121
- | `serve_static` | If we should serve static resources. Set it to `false` if your web server is already doing it. |
110
+ | Key | Default | Description |
111
+ | --------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------- |
112
+ | `mpd_host` | `127.0.0.1` | MPD host. |
113
+ | `mpd_port` | `6600` | MPD port. |
114
+ | `mpd_password` | `""` (none) | MPD password. |
115
+ | `streams_file` | `/etc/pifi_streams.json` | Path to the JSON file containing the streams. |
116
+ | `streamsp_file` | `""` (none) | Path to JSON file containing additional streams. These will be shown only to the devices listed on `special_ips`. |
117
+ | `special_ips` | `""` (none) | The IPs of the devices to show additional streams. |
118
+ | `play_local` | `false` | Set it to `true` if you want PiFi to play songs from your local library. This shows the "Random" button. |
119
+ | `serve_static` | `true` | If we should serve static resources. Set it to `false` if your web server is already doing it. |
122
120
 
123
- [You can find a sample here](docs/pifi.json.sample). I suggest you download it and edit it to your needs:
121
+ If you want to change any of these options, download the sample file and edit it to your needs:
124
122
 
125
123
  ```
126
124
  $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/pifi.json.sample -O /etc/pifi.json
127
125
  $ sudo -e /etc/pifi.json
128
126
  ```
129
127
 
128
+ ## Usage
129
+
130
+ PiFi can be run:
131
+
132
+ - With the `pifi` command. Check `pifi -h` for the options available.
133
+ - [If you installed the systemd service](INSTALL.md#running-at-system-boot-and-as-other-user), with `sudo systemctl start pifi`.
134
+ - At boot enabling the systemd service with `sudo systemctl enable pifi`.
135
+
136
+ On your mobile browser, I suggest you add PiFi Radio to your home screen, for easier access.
137
+
130
138
  ## Credits
131
139
 
132
140
  - Translation fr-fr: Francis Chavanon "rimeno"
@@ -23,7 +23,7 @@ module PiFi
23
23
  private
24
24
 
25
25
  def parse_config
26
- if File.exists?(PATH)
26
+ if File.file?(PATH)
27
27
  warn "Config found at #{PATH}."
28
28
  config = file_to_hash(PATH)
29
29
  else
@@ -4,9 +4,10 @@ module PiFi
4
4
  class StreamsGetter
5
5
  include Utils
6
6
 
7
- def initialize(path_pub, path_priv)
7
+ def initialize(path_pub, path_priv="")
8
8
  @path_pub = path_pub
9
9
  @path_priv = path_priv
10
+ check_paths
10
11
  end
11
12
 
12
13
  def streams
@@ -23,5 +24,13 @@ module PiFi
23
24
 
24
25
  {pub: pub, all: all}
25
26
  end
27
+
28
+ def check_paths
29
+ raise ArgumentError, "Streams file not found at '#{@path_pub}'" unless File.file?(@path_pub)
30
+ if ! @path_priv.empty? && ! File.file?(@path_priv)
31
+ warn "Additional streams file not found at '#{@path_priv}'"
32
+ @path_priv = ""
33
+ end
34
+ end
26
35
  end
27
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pifi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Cavalcanti