kollus 0.0.2 → 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 +4 -4
- data/lib/kollus.rb +35 -11
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e0a6be514de4da5bf042caf193b8b3cc8f6d20
|
4
|
+
data.tar.gz: d4fdc2b8df76cea9bbfc8cc0251cfce545e0adf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22cdbc84db3b6ad6a2b858edeb48c88bb5f9671052324480a2c449ab93df9662de253631d01f5a4a3ae15fcb40ae39fbf0ac28b5bef989cfce0554e63e0a1277
|
7
|
+
data.tar.gz: 913b596a88ac0f2955c417835da72a351111af951d0779143ed16dcf04b54eed029242ba4d6ae44a32156f31ffd48703041c96a7657c1bd0179c38a6b2257bc0
|
data/lib/kollus.rb
CHANGED
@@ -1,23 +1,40 @@
|
|
1
|
+
# Copyright 2015-2016 Hyeon Kim
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
5
|
+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
6
|
+
# option. This file may not be copied, modified, or distributed
|
7
|
+
# except according to those terms.
|
8
|
+
|
1
9
|
require 'net/http'
|
2
10
|
require 'json'
|
3
11
|
|
4
12
|
class Kollus
|
5
|
-
def initialize(
|
6
|
-
@id = account_id
|
13
|
+
def initialize(account_key, api_token)
|
7
14
|
@key = account_key
|
8
15
|
@token = api_token
|
9
16
|
end
|
10
17
|
|
11
|
-
def
|
18
|
+
def detail(upload_key)
|
19
|
+
api_uri = URI("http://api.kr.kollus.com/0//media/library/media_content/#{upload_key}?access_token=#{@token}")
|
20
|
+
|
21
|
+
response = Net::HTTP.get(api_uri)
|
22
|
+
response = JSON.parse response
|
23
|
+
|
24
|
+
return nil unless response['error'] == 0
|
25
|
+
return response['result']
|
26
|
+
end
|
27
|
+
|
28
|
+
def media(media_content_key, client_user_id, media_profile_key = nil, awt_code = nil, expire_time = 7200, playlist_flag = nil)
|
12
29
|
api_uri = URI('http://api.kr.kollus.com/0/media_auth/media_token/get_media_link_by_userid?access_token=' + @token)
|
13
30
|
params = {
|
14
|
-
client_user_id:
|
31
|
+
client_user_id: client_user_id,
|
15
32
|
security_key: @key,
|
16
33
|
media_content_key: media_content_key,
|
17
34
|
media_profile_key: media_profile_key,
|
18
35
|
awt_code: awt_code,
|
19
36
|
expire_time: expire_time,
|
20
|
-
|
37
|
+
playlist_flag: playlist_flag
|
21
38
|
}
|
22
39
|
|
23
40
|
response = Net::HTTP.post_form(api_uri, params)
|
@@ -51,13 +68,14 @@ class Kollus
|
|
51
68
|
end
|
52
69
|
|
53
70
|
|
54
|
-
def upload(title = nil, expire_time = 600, encrypted = true, audio = false)
|
71
|
+
def upload(category_key = nil, title = nil, expire_time = 600, encrypted = true, audio = false)
|
72
|
+
tries ||= 3
|
55
73
|
api_uri = URI('http://api.kr.kollus.com/0/media_auth/upload/create_url.json?access_token=' + @token)
|
56
74
|
params = {
|
57
75
|
# 값의 범위는 0 < expire_time <= 21600 입니다. 빈값을 보내거나 항목 자체를 제거하면 기본 600초로 설정됩니다.
|
58
76
|
expire_time: expire_time,
|
59
77
|
# 업로드한 파일이 속할 카테고리의 키(API를 이용하여 확득 가능)입니다. 빈값을 보내 거나 항목 자체를 제거하면 '없음'에 속합니다.
|
60
|
-
category_key:
|
78
|
+
category_key: category_key,
|
61
79
|
# 입력한 제목을 컨텐츠의 제목으로 강제지정합니다. 이 값을 보내지 않거나 빈값으로 보내면 기본 적으로 파일명이 제목으로 사용됩니다.
|
62
80
|
title: title,
|
63
81
|
# 0은 일반 업로드, 1은 암호화 업로드입니다. 암호화 업로드시 파일이 암호화 되어 Kollus의 전용 플레이어로만 재생됩니다.
|
@@ -74,12 +92,12 @@ class Kollus
|
|
74
92
|
response = JSON.parse response.body
|
75
93
|
# TODO: Error handling
|
76
94
|
|
77
|
-
unless response['error'] == 0
|
78
|
-
# TODO: Error handling
|
79
|
-
return nil
|
80
|
-
end
|
95
|
+
raise KollusError, response unless response['error'] == 0
|
81
96
|
|
82
97
|
UploadSession.new response['result']
|
98
|
+
rescue KollusError => e
|
99
|
+
retry unless (tries -= 1).zero?
|
100
|
+
raise e
|
83
101
|
end
|
84
102
|
|
85
103
|
class UploadSession
|
@@ -94,3 +112,9 @@ class Kollus
|
|
94
112
|
def expires_at; @expires_at end
|
95
113
|
end
|
96
114
|
end
|
115
|
+
|
116
|
+
class KollusError < StandardError
|
117
|
+
def initialize(msg = 'Error with Kollus')
|
118
|
+
super(msg)
|
119
|
+
end
|
120
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kollus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hyeon Kim
|
8
|
+
- Yi Sang-won Leo
|
9
|
+
- Gyumin Sim
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date:
|
13
|
+
date: 2016-12-10 00:00:00.000000000 Z
|
12
14
|
dependencies: []
|
13
15
|
description: Kollus API written in ruby.
|
14
16
|
email: simnalamburt@gmail.com
|
@@ -19,6 +21,7 @@ files:
|
|
19
21
|
- lib/kollus.rb
|
20
22
|
homepage: https://github.com/simnalamburt/kollus-ruby
|
21
23
|
licenses:
|
24
|
+
- Apache-2.0
|
22
25
|
- MIT
|
23
26
|
metadata: {}
|
24
27
|
post_install_message:
|
@@ -37,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
40
|
version: '0'
|
38
41
|
requirements: []
|
39
42
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.
|
43
|
+
rubygems_version: 2.5.2
|
41
44
|
signing_key:
|
42
45
|
specification_version: 4
|
43
46
|
summary: Kollus API written in ruby
|