radio5 0.1.0 → 0.1.1

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: edd4e5e61372538e86183d4e6171031695c51379482a619eb29c0b94378906e9
4
- data.tar.gz: d25d7a72fdb56988bb4ae585a986671a395da01476fffa24f2ddb25d152fb85d
3
+ metadata.gz: 2dbd8b7a0f0f52fbd61723bdadc3ce5391e06569ac5dd14af9179a5686b7144c
4
+ data.tar.gz: ace0a638624953a08f543ddb34646c2a13b2f661db12e79ca3527184d9723410
5
5
  SHA512:
6
- metadata.gz: 94aeac4d8c3d39c751c22f5104c4f08fffa41c48f74db24f5ac984ee4f10d1f372f2bed4e361230a59f0791884adada50fa690bb8a42b523384a8ab6801f9622
7
- data.tar.gz: 21475735cdf9bfc455c8a8841cdead2ab67b2e6e25503daf04c7fdd71eb32ce62f9cb8161a2c3a2f214a1365149efc4ea0711f58488fc8cdb64f74ebb52aeb3b
6
+ metadata.gz: 1a6ba08b636344e53094fd718f7c63f60047ebb5ea8e12d0e274f4bb828792cc0eeb9748d3ecbe718d409c573c76c0e3632bcd2214ed7bd9702078a0572db4dd
7
+ data.tar.gz: b42658c994bb9dd6b0c1b06bd97f9eb19032031a6f82752dbcc1bd0d8d8bdbfad1da647a0f20bf8f51b83481546ab1c1b2f397d7359c5b62f9786e951b53a31e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.1.1
2
+ ----------
3
+
4
+ - Added `max_retries` config option for `Client`
5
+ - All constants are now frozen
6
+
1
7
  0.1.0
2
8
  ----------
3
9
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Radio5
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/radio5.svg)](https://badge.fury.io/rb/radio5)
3
4
  [![Build](https://github.com/ocvit/radio5/workflows/Build/badge.svg)](https://github.com/ocvit/radio5/actions)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/ocvit/radio5/badge.svg?branch=main)](https://coveralls.io/github/ocvit/radio5?branch=main)
5
6
 
@@ -41,6 +42,7 @@ client = Radio5::Client.new(
41
42
  read_timeout: 30, # default: 10
42
43
  write_timeout: 30, # default: 10
43
44
  proxy_url: "http://user:pass@123.4.56.178:80", # default: nil
45
+ max_retries: 5, # for network errors, default: 3
44
46
  debug_output: $stdout # default: nil
45
47
  )
46
48
  ```
@@ -222,7 +224,7 @@ There is just a couple of features that require login and/or premium account:
222
224
 
223
225
  - history of "listened" tracks - track becomes "listened" when you got it via `#random_track` or `#island_track` (free)
224
226
  - `followed` flag for `#user` - indicates whether or not you follow this user (free)
225
- - `#user_liked_tracks` - list of tracks which user really rock'n'roll'ed to (free)
227
+ - `#user_liked_tracks` - list of tracks which user really vibed to (free)
226
228
  - ability to use multiple countries as a filter in `#random_track` (premium)
227
229
 
228
230
  Currently auth is in a WIP state.
data/lib/radio5/api.rb CHANGED
@@ -58,6 +58,7 @@ module Radio5
58
58
  read_timeout: client.read_timeout,
59
59
  write_timeout: client.write_timeout,
60
60
  proxy_url: client.proxy_url,
61
+ max_retries: client.max_retries,
61
62
  debug_output: client.debug_output
62
63
  )
63
64
  end
data/lib/radio5/client.rb CHANGED
@@ -9,12 +9,20 @@ module Radio5
9
9
  include Islands
10
10
  include Tracks
11
11
 
12
- attr_accessor :open_timeout, :read_timeout, :write_timeout, :proxy_url, :debug_output
12
+ attr_accessor :open_timeout, :read_timeout, :write_timeout, :proxy_url, :max_retries, :debug_output
13
13
 
14
- def initialize(open_timeout: nil, read_timeout: nil, write_timeout: nil, proxy_url: nil, debug_output: nil)
14
+ def initialize(
15
+ open_timeout: nil,
16
+ read_timeout: nil,
17
+ write_timeout: nil,
18
+ proxy_url: nil,
19
+ max_retries: nil,
20
+ debug_output: nil
21
+ )
15
22
  @open_timeout = open_timeout
16
23
  @read_timeout = read_timeout
17
24
  @write_timeout = write_timeout
25
+ @max_retries = max_retries
18
26
  @proxy_url = proxy_url
19
27
  @debug_output = debug_output
20
28
  end
data/lib/radio5/http.rb CHANGED
@@ -9,12 +9,12 @@ module Radio5
9
9
  DEFAULT_OPEN_TIMEOUT = 10 # seconds
10
10
  DEFAULT_READ_TIMEOUT = 10 # seconds
11
11
  DEFAULT_WRITE_TIMEOUT = 10 # seconds
12
- DEFAULT_DEBUG_OUTPUT = File.open(File::NULL, "w")
12
+ DEFAULT_DEBUG_OUTPUT = nil
13
13
  DEFAULT_MAX_RETRIES = 3
14
14
  DEFAULT_HEADERS = {
15
15
  "Content-Type" => "application/json; charset=utf-8",
16
16
  "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
17
- }
17
+ }.freeze
18
18
  RETRIABLE_ERRORS = [
19
19
  Errno::ECONNREFUSED,
20
20
  Errno::ECONNRESET,
@@ -23,9 +23,7 @@ module Radio5
23
23
  Net::ReadTimeout,
24
24
  Net::WriteTimeout,
25
25
  OpenSSL::SSL::SSLError
26
- ]
27
-
28
- attr_reader :max_retries
26
+ ].freeze
29
27
 
30
28
  # rubocop:disable Layout/ExtraSpacing
31
29
  def initialize(
@@ -113,7 +111,7 @@ module Radio5
113
111
  def make_request(request, retries: 0)
114
112
  @http.request(request)
115
113
  rescue *RETRIABLE_ERRORS => error
116
- if retries < max_retries
114
+ if retries < @max_retries
117
115
  make_request(request, retries: retries + 1)
118
116
  else
119
117
  raise error
@@ -4,12 +4,12 @@ module Radio5
4
4
  module Regexps
5
5
  # rubocop:disable Layout/ExtraSpacing
6
6
 
7
- MONGO_ID = /^[a-f\d]{24}$/
8
- UUID_GENERIC = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
9
- UUID = /^#{UUID_GENERIC}$/
7
+ MONGO_ID = /^[a-f\d]{24}$/.freeze
8
+ UUID_GENERIC = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/.freeze
9
+ UUID = /^#{UUID_GENERIC}$/.freeze
10
10
 
11
- COUNTRY_ISO_CODE_GENERIC = /([A-Z]{3}|KN1)/
12
- COUNTRY_ISO_CODE = /^#{COUNTRY_ISO_CODE_GENERIC}$/
11
+ COUNTRY_ISO_CODE_GENERIC = /([A-Z]{3}|KN1)/.freeze
12
+ COUNTRY_ISO_CODE = /^#{COUNTRY_ISO_CODE_GENERIC}$/.freeze
13
13
 
14
14
  ASSET_URL = lambda do |sub_path, exts|
15
15
  asset_host = Regexp.escape(Utils::ASSET_HOST)
@@ -17,21 +17,21 @@ module Radio5
17
17
  exts = /(#{exts.join("|")})/
18
18
 
19
19
  /#{asset_host}#{sub_path}\/#{UUID_GENERIC}(_\d+)?\.#{exts}/
20
- end
20
+ end.freeze
21
21
 
22
- ISLAND_ICON_URL = ASSET_URL.call("/island/icon", ["png", "svg"])
23
- ISLAND_SPLASH_URL = ASSET_URL.call("/island/splash", ["png", "svg"])
24
- ISLAND_MARKER_URL = ASSET_URL.call("/island/marker", ["png", "svg"])
25
- TRACK_COVER_URL = ASSET_URL.call(/\/cover\/#{COUNTRY_ISO_CODE_GENERIC}\/\d{4}\/large/, ["jpg", "jpeg"])
22
+ ISLAND_ICON_URL = ASSET_URL.call("/island/icon", ["png", "svg"]).freeze
23
+ ISLAND_SPLASH_URL = ASSET_URL.call("/island/splash", ["png", "svg"]).freeze
24
+ ISLAND_MARKER_URL = ASSET_URL.call("/island/marker", ["png", "svg"]).freeze
25
+ TRACK_COVER_URL = ASSET_URL.call(/\/cover\/#{COUNTRY_ISO_CODE_GENERIC}\/\d{4}\/large/, ["jpg", "jpeg"]).freeze
26
26
 
27
27
  AUDIO_URL = lambda do |exts|
28
28
  exts = /(#{exts.join("|")})/
29
29
 
30
30
  /.+\/#{UUID_GENERIC}\.#{exts}\?token=[^&]{22}&expires=\d{10}$/
31
- end
31
+ end.freeze
32
32
 
33
- MPEG_URL = AUDIO_URL.call(["mp3", "m4a"])
34
- OGG_URL = AUDIO_URL.call(["ogg"])
33
+ MPEG_URL = AUDIO_URL.call(["mp3", "m4a"]).freeze
34
+ OGG_URL = AUDIO_URL.call(["ogg"]).freeze
35
35
 
36
36
  # rubocop:enable Layout/ExtraSpacing
37
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Radio5
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radio5
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Horoshko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Adapter for Radiooooo.com private API.
13
+ description: Adapter for Radiooooo private API.
14
14
  email:
15
15
  - electric.molfar@gmail.com
16
16
  executables: []
@@ -58,5 +58,5 @@ requirements: []
58
58
  rubygems_version: 3.4.10
59
59
  signing_key:
60
60
  specification_version: 4
61
- summary: Radiooooo.com unlocked!
61
+ summary: Adapter for Radiooooo private API
62
62
  test_files: []