1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
extern crate dotenv;
extern crate futures;
extern crate serde;
extern crate tokio;
extern crate twitch_api;
use futures::future::Future;
use futures::Stream;
use std::env;
use twitch_api::HelixClient;
use twitch_api::KrakenClient;
use std::str::FromStr;
use twitch_api::types::UserId;
use twitch_api::types::ClipId;
fn main() {
dotenv::dotenv().unwrap();
let client_id = &env::var("TWITCH_API").unwrap();
let helix_client = HelixClient::new(client_id);
let kraken_client = KrakenClient::new(client_id);
/*
.authenticate(&env::var("TWITCH_SECRET").unwrap())
.build();
*/
let clip = helix_client
.clips()
.clip(&ClipId::new("EnergeticApatheticTarsierThisIsSparta"))
.map_err(|err| {
println!("{:?}", err);
()
});
/*
let clip2 = authed_client
.clips()
.clip(&"EnergeticApatheticTarsierThisIsSparta")
.map_err(|err| {
println!("{:?}", err);
()
});
*/
//use twitch_api::types::VideoId;
/*
let videos = authed_client
.videos()
.by_user(&UserId::from_str("19571641").unwrap())
.take(1)
.for_each(|collection| {
println!("{:?}", collection);
Ok(())
})
.map(|_| ())
.map_err(|err| {println!("{:?}", err); ()});
*/
let clip2 = kraken_client
.clips()
.clip(&"EnergeticApatheticTarsierThisIsSparta")
.map_err(|err| {
println!("{:?}", err);
()
});
let u = helix_client
.users()
.users(&vec!(), &vec!("freakey"))
.map(|res| {println!("{:?}", res); ()})
.map_err(|res| {println!("{:?}", res); ()});
/* Prevents tokio from **hanging**
* since tokio::run blocks the current thread and waits for the entire runtime
* to become idle but it will never becomes idle since we keep a reference
* to a reqwest client which maintains a connection pool.
*/
//std::mem::drop(authed_client);
tokio::run(
u
/*
clip.join(clip2)
.and_then(|(c1, c2)| {
println!("{:?}", c1);
println!("__");
println!("{:?}", c2);
Ok((c1, c2))
}).and_then(move |_| {
helix_client
.clips()
.clip(&ClipId::new("EnergeticApatheticTarsierThisIsSparta"))
.map(|_| ())
.map_err(|err| {
println!("{:?}", err);
()
})
})
.map(|_| ())
.map_err(|_| ())
*/
/*videos*/
);
}
|