-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
79 lines (61 loc) · 2.4 KB
/
Program.cs
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
using Newtonsoft.Json;
using project_BlueBird.Items;
using System;
using System.IO;
namespace project_BlueBird
{
class Program
{
static void Main(string[] args)
{
CoreProcessing coreProcessing = new CoreProcessing();
Console.WriteLine("Creating/Validating ingest directory...");
string currentDirectory = System.IO.Directory.GetCurrentDirectory();
FileIO.CheckAndCreateDir(currentDirectory + "/ingest");
/*
* Read in twitter credentials
*/
if(!File.Exists(currentDirectory + "/ingest/credentials.json"))
{
Console.WriteLine("Credential file does not exist!");
return;
}
else
{
Console.WriteLine("");
}
//Read in from JSON file
StreamReader r = new StreamReader(currentDirectory + "/ingest/credentials.json");
string json = r.ReadToEnd();
TwitterCredsJSON credentials = JsonConvert.DeserializeObject<TwitterCredsJSON>(json);
//Build twitter connection using credentials
coreProcessing.InitialiseConnection(credentials);
/*
* Read in usernames
*/
if (!File.Exists(currentDirectory + "/ingest/credentials.json"))
{
Console.WriteLine("Credential file does not exist!");
return;
}
//Read in from TXT file
string txtFile = System.IO.File.ReadAllText(currentDirectory + "/ingest/DownloadNames.txt");
string[] usrNms = txtFile.Split(new[] { ',', ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries); //Split entries
foreach (string usrNm in usrNms)
{
//Fetch user and get tweets & media
coreProcessing.ProcessTwitterUser(usrNm, currentDirectory);
Console.WriteLine("");
}
Console.WriteLine("Finished operations.");
//Consider looking into Twitter-Lists in the future (https://github.com/linvi/tweetinvi/wiki/Twitter-Lists)
}
}
public class TwitterCredsJSON
{
public string ConsumerKey { get; set; }
public string ConsumerSecret { get; set; }
public string AccessToken { get; set; }
public string AccessTokenSecret { get; set; }
}
}