summaryrefslogtreecommitdiff
path: root/src/extractors/extractor.c
blob: 06d52a5522ca293c403064b74d6bf58618036daf (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
#include <stdlib.h>

#include "../utils/utils.h"
#include "bilibili.h"
#include "extractor.h"
#include "haokan.h"
#include "youku.h"

Site_map site_map = {{{"www.bilibili.com", SITE_BILIBILI},
                      {"haokan.baidu.com", SITE_HAOKAN},
                      {"v.youku.com", SITE_YOUKU}},
                     3};

void options_cleanup(Options *options) {
  FREE_AND_NULLIFY(options->URL);
  FREE_AND_NULLIFY(options->path);
  FREE_AND_NULLIFY(options->query);
  FREE_AND_NULLIFY(options->pagedata);
}

int extract(void *v) {
  Options *options = (Options *)v;
  switch (options->site) {
  case SITE_BILIBILI:
    bilibili_extract(options);
    break;
  case SITE_HAOKAN:
    haokan_extract(options);
    break;
  case SITE_YOUKU:
    youku_extract(options);
    break;
  }
  options_cleanup(options);
  return 0;
}