blob: 3cfbd414d4cf4faa5de1ea9cbfcfedfb80e07503 (
plain)
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
|
/*sfdb_freesound_mootcher.h****************************************************************************
Adapted for Ardour by Ben Loftis, March 2008
Mootcher Online Access to thefreesoundproject website
http://freesound.iua.upf.edu/
GPL 2005 Jorn Lemon
mail for questions/remarks: mootcher@twistedlemon.nl
or go to the freesound website forum
*****************************************************************************/
#include <string>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
//#include <ctime>
#include "curl/curl.h"
// mootcher version
#define ___VERSION___ 1.3
//--- struct to store XML file
struct MemoryStruct {
char *memory;
size_t size;
};
//--- for download process viewing
struct dlprocess {
double dltotalMoo;
double dlnowMoo;
};
class Mootcher
{
public:
Mootcher(const char *saveLocation);
~Mootcher();
int doLogin(std::string login, std::string password);
std::string getFile(std::string ID);
std::string searchText(std::string word);
struct dlprocess bar;
private:
const char* changeWorkingDir(const char *saveLocation);
std::string getXmlFile(std::string ID, int &length);
void GetXml(std::string ID, struct MemoryStruct &xml_page);
std::string changeExtension(std::string filename);
void toLog(std::string input);
void setcUrlOptions();
static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
CURL *curl;
char errorBuffer[CURL_ERROR_SIZE]; // storage for cUrl error message
int connection; // is 0 if no connection
char message[128]; // storage for messages that are send to the logfile
std::string basePath;
std::string xmlLocation;
};
|