qingting_api 0.1.5 → 0.3.0

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.
data/qingting_api.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'qingting_api/version'
4
+ require 'qingting/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "qingting_api"
8
- s.version = QingtingApi::VERSION
8
+ s.version = Qingting::VERSION
9
9
  s.authors = ["cheenwe"]
10
- s.email = ["cheenwe@gmail.com"]
10
+ s.email = ["cxhyun@126.com"]
11
11
 
12
- s.summary = "Qingting Fm ruby api"
13
- s.description = "Qingting Fm ruby api"
12
+ s.summary = "QingtingFM ruby api"
13
+ s.description = "蜻蜓 FM Ruby API"
14
14
  s.homepage = "https://github.com/cheenwe/qingting_api"
15
15
  s.license = "MIT"
16
16
 
@@ -20,11 +20,11 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ['lib']
21
21
 
22
22
 
23
- s.add_dependency 'activerecord', ['>= 3.0', '< 5.0']
24
- s.add_dependency 'activesupport', ['>= 3.0', '< 5.0']
23
+ # s.add_dependency 'activerecord', ['>= 3.0']
24
+ # s.add_dependency 'activesupport', ['>= 3.0']
25
25
 
26
26
  s.add_development_dependency 'bundler', ['>= 1.0.0']
27
27
  s.add_development_dependency 'rake', ['>= 0']
28
- s.add_development_dependency 'rails', ['>= 3.1.0']
29
- s.add_development_dependency "rspec"
28
+ # s.add_development_dependency 'rails', ['>= 3.1.0']
29
+ # s.add_development_dependency "rspec"
30
30
  end
metadata CHANGED
@@ -1,55 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qingting_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cheenwe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2017-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activerecord
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '3.0'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '5.0'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '3.0'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '5.0'
33
- - !ruby/object:Gem::Dependency
34
- name: activesupport
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '3.0'
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '5.0'
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '3.0'
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '5.0'
53
13
  - !ruby/object:Gem::Dependency
54
14
  name: bundler
55
15
  requirement: !ruby/object:Gem::Requirement
@@ -78,56 +38,36 @@ dependencies:
78
38
  - - ">="
79
39
  - !ruby/object:Gem::Version
80
40
  version: '0'
81
- - !ruby/object:Gem::Dependency
82
- name: rails
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: 3.1.0
88
- type: :development
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: 3.1.0
95
- - !ruby/object:Gem::Dependency
96
- name: rspec
97
- requirement: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: '0'
109
- description: Qingting Fm ruby api
41
+ description: 蜻蜓 FM Ruby API
110
42
  email:
111
- - cheenwe@gmail.com
112
- executables: []
43
+ - cxhyun@126.com
44
+ executables:
45
+ - console
113
46
  extensions: []
114
47
  extra_rdoc_files: []
115
48
  files:
116
49
  - ".gitignore"
117
- - ".travis.yml"
118
50
  - CODE_OF_CONDUCT.md
119
51
  - Gemfile
120
52
  - LICENSE.txt
121
53
  - README.md
122
54
  - Rakefile
55
+ - bin/console
123
56
  - lib/generators/qingting_api/config_generator.rb
124
57
  - lib/generators/qingting_api/templates/qingting_api_config.rb
58
+ - lib/qingting/api/account.rb
59
+ - lib/qingting/api/base.rb
60
+ - lib/qingting/api/billboard.rb
61
+ - lib/qingting/api/category.rb
62
+ - lib/qingting/api/live.rb
63
+ - lib/qingting/api/ondemand.rb
64
+ - lib/qingting/api/podcaster.rb
65
+ - lib/qingting/api/recent.rb
66
+ - lib/qingting/config.rb
67
+ - lib/qingting/utils/http.rb
68
+ - lib/qingting/utils/request.rb
69
+ - lib/qingting/version.rb
125
70
  - lib/qingting_api.rb
126
- - lib/qingting_api/account.rb
127
- - lib/qingting_api/config.rb
128
- - lib/qingting_api/qing_ting.rb
129
- - lib/qingting_api/request.rb
130
- - lib/qingting_api/version.rb
131
71
  - qingting_api.gemspec
132
72
  homepage: https://github.com/cheenwe/qingting_api
133
73
  licenses:
@@ -149,9 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
89
  version: '0'
150
90
  requirements: []
151
91
  rubyforge_project:
152
- rubygems_version: 2.5.0
92
+ rubygems_version: 2.5.1
153
93
  signing_key:
154
94
  specification_version: 4
155
- summary: Qingting Fm ruby api
95
+ summary: QingtingFM ruby api
156
96
  test_files: []
157
- has_rdoc:
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.0.0
5
-
6
- script:
7
- - bundle exec rspec spec
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
- require 'net/http'
3
- require 'active_support/json'
4
-
5
- module QingtingApi
6
- # Module that handle user information
7
- #
8
- module Account
9
- module_function
10
-
11
- # 获取账户 token
12
- #
13
- def access_token
14
- post 'access', grant_type: "client_credentials", client_id: QingtingApi.config.client_id, client_secret:QingtingApi.config.client_secret
15
- end
16
-
17
-
18
- def post(api, options = {})
19
- uri = URI.join(QingtingApi.config.base_url, api)
20
- res = Net::HTTP.post_form(uri, options)
21
- result res.body
22
- end
23
-
24
-
25
- def result(body)
26
- begin
27
- resule = ActiveSupport::JSON.decode body
28
- resule['access_token']
29
- rescue => e
30
- {
31
- code: 502,
32
- msg: '内容解析错误',
33
- detail: e.to_s
34
- }
35
- end
36
- end
37
- end
38
- end
@@ -1,44 +0,0 @@
1
- # encoding: utf-8
2
- require 'active_support/configurable'
3
- require 'active_support/core_ext'
4
-
5
- module QingtingApi
6
-
7
- # curl -X POST "http://api.open.qingting.fm/access?&grant_type=client_credentials" -d "client_id=ZTk4MzAwMzAtYWFiOC0xMWU0LTkyM2YtMDAxNjNlMDAyMGFk&client_secret=OTdiNmI0MWEtYzhiZC0zYWE1LWExZmEtMDU0OWZhNTljZmRk"
8
-
9
- # client_id和client_secret,用以后续获取access_token
10
- def self.configure(&block)
11
- yield @config ||= QingtingApi::Configuration.new
12
- end
13
-
14
- # Global settings for QingtingApi
15
- def self.config
16
- @config
17
- end
18
-
19
- # Configuration class
20
- #
21
- class Configuration #:nodoc:
22
- include ActiveSupport::Configurable
23
- # client_id和client_secret,用以后续获取access_token
24
- config_accessor :base_url # api url
25
- config_accessor :client_id # 授权 API client_id
26
- config_accessor :client_secret # 授权 API client_secret
27
- config_accessor :api_version # API 的版本,目前有v6
28
- config_accessor :page_num # 获取信息时, 指定默认的页数
29
- config_accessor :page_size # 获取信息时, 一页包含信息数量
30
- config_accessor :company # 默认公司名称
31
- config_accessor :expires_in # 过期时间。当access_token过期时,API会返回token_expired错误。这时需要重新申请access token
32
- end
33
-
34
- configure do |config|
35
- config.base_url = "http://api.open.qingting.fm"
36
- config.client_id = "ZTk4MzAwMzAtYWFiOC0xMWU0LTkyM2YtMDAxNjNlMDAyMGFk"
37
- config.client_secret = "OTdiNmI0MWEtYzhiZC0zYWE1LWExZmEtMDU0OWZhNTljZmRk"
38
- config.api_version = :v6
39
- config.page_num = 1
40
- config.page_size = 30
41
- config.company = 'Cheenwe'
42
- config.expires_in = 7200.second
43
- end
44
- end
@@ -1,70 +0,0 @@
1
- module QingtingApi
2
- # Message service: methods that are used to manage messages
3
- module QingTing
4
-
5
- def self.included(base)
6
- base.send :extend, ClassMethods
7
- end
8
-
9
- # Class methods
10
- module ClassMethods
11
-
12
- def find_by_cid(cmode, cid)
13
- Request.get "#{cmode}", cid: cid
14
- end
15
-
16
- def method_missing(name, *args)
17
- if name != /^get_(.*)/
18
- Request.get "/#{QingtingApi.config.api_version}/media/#{name}?access_token=#{token}"
19
- else
20
- {
21
- code: 404,
22
- msg: 'NOT FIND'
23
- }
24
- end
25
- end
26
-
27
- def get(name)
28
- Request.get "/#{QingtingApi.config.api_version}/media/#{name}?access_token=#{token}"
29
- end
30
-
31
- def get_id(name, id)
32
- Request.get "/#{QingtingApi.config.api_version}/media/#{name}/#{id}?access_token=#{token}"
33
- end
34
-
35
- def catrgory_channel(category_id, curpage, page_size={})
36
- if page_size.present?
37
- Request.get "/#{QingtingApi.config.api_version}/media/categories/#{category_id}/channels/order/0/curpage/#{curpage}/pagesize/#{page_size}?access_token=#{token}"
38
- else
39
- Request.get "/#{QingtingApi.config.api_version}/media/categories/#{category_id}/channels/order/0/curpage/#{curpage}/pagesize/#{QingtingApi.config.page_size}?access_token=#{token}"
40
- end
41
- end
42
-
43
- def ondemand_channel(category_id, curpage, page_size={})
44
- if page_size.present?
45
- Request.get "/#{QingtingApi.config.api_version}/media/channelondemands/#{category_id}/programs/curpage/#{curpage}/pagesize/#{page_size}?access_token=#{token}"
46
- else
47
- Request.get "/#{QingtingApi.config.api_version}/media/channelondemands/#{category_id}/programs/curpage/#{curpage}/pagesize/#{QingtingApi.config.page_size}?access_token=#{token}"
48
- end
49
- end
50
-
51
- def live_channel(channel_id, day)
52
- Request.get "/#{QingtingApi.config.api_version}/media/channellives/#{channel_id}/programs/day/#{day}?access_token=#{token}"
53
- end
54
-
55
- def search(keyword, type={})
56
- if type.present?
57
- Request.get "/search/#{CGI.escape(keyword)}/type/#{type}?access_token=#{token}"
58
- else
59
- Request.get "/search/#{CGI.escape(keyword)}/type/all?access_token=#{token}"
60
- end
61
- end
62
-
63
- def token
64
- QingtingApi::Account.access_token
65
- end
66
-
67
- end
68
-
69
- end
70
- end
@@ -1,52 +0,0 @@
1
- # encoding: utf-8
2
- require 'net/http'
3
- require 'active_support/json'
4
-
5
- module QingtingApi
6
- # Module that manage requests
7
- module Request
8
- # Method that use `Net::HTTP.post_form` to perform `POST` action
9
- #
10
- def post(api, options = {})
11
- uri = URI.join(base_url, api)
12
- res = Net::HTTP.post_form(uri, options)
13
- result res.body
14
- end
15
-
16
- # Method that use `Net::HTTP.get` to perform `GET` action
17
- #
18
- def get(api, options = {})
19
- url = URI.join(base_url, api)
20
- result Net::HTTP.get(url)
21
-
22
- # uri = URI('http://example.com/index.html')
23
- # params = { :limit => 10, :page => 3 }
24
- # uri.query = URI.encode_www_form(params)
25
-
26
- # res = Net::HTTP.get_response(uri)
27
- end
28
-
29
- private
30
-
31
- # Method that parse JSON to Hash
32
- #
33
- def result(body)
34
- begin
35
- ActiveSupport::JSON.decode body
36
- rescue => e
37
- {
38
- code: 502,
39
- msg: '内容解析错误',
40
- detail: e.to_s
41
- }
42
- end
43
- end
44
-
45
- # Base uri for Qingting API
46
- def base_url
47
- "#{QingtingApi.config.base_url}"
48
- end
49
-
50
- module_function :post, :get, :result, :base_url
51
- end
52
- end
@@ -1,3 +0,0 @@
1
- module QingtingApi
2
- VERSION = "0.1.5"
3
- end