aboutsummaryrefslogtreecommitdiff
path: root/bridges/FurAffinityUserBridge.php
blob: d9214b84b352eae759aeb1f925d85b72ca6dffbb (plain) (blame)
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
<?php
class FurAffinityUserBridge extends BridgeAbstract {
	const NAME = 'FurAffinity User Gallery';
	const URI = 'https://www.furaffinity.net';
	const MAINTAINER = 'CyberJacob';
	const DESCRIPTION = 'See https://rss-bridge.github.io/rss-bridge/Bridge_Specific/Furaffinityuser.html for explanation';
	const PARAMETERS = array(
		array(
			'searchUsername' => array(
				'name' => 'Search Username',
				'type' => 'text',
				'required' => true,
				'title' => 'Username to fetch the gallery for',
				'exampleValue' => 'armundy',
			),
			'aCookie' => array(
				'name' => 'Login cookie \'a\'',
				'type' => 'text',
				'required' => true
			),
			'bCookie' => array(
				'name' => 'Login cookie \'b\'',
				'type' => 'text',
				'required' => true
			)
		)
	);

	public function collectData() {
		$opt = array(CURLOPT_COOKIE => 'b=' . $this->getInput('bCookie') . '; a=' . $this->getInput('aCookie'));

		$url = self::URI . '/gallery/' . $this->getInput('searchUsername');

		$html = getSimpleHTMLDOM($url, array(), $opt)
			or returnServerError('Could not load the user\'s gallery page.');

		$submissions = $html->find('section[id=gallery-gallery]', 0)->find('figure');
		foreach($submissions as $submission) {
			$item = array();
			$item['title'] = $submission->find('figcaption', 0)->find('a', 0)->plaintext;

			$thumbnail = $submission->find('a', 0);
			$thumbnail->href = self::URI . $thumbnail->href;

			$item['content'] = $submission->find('a', 0);

			$this->items[] = $item;
		}
	}

	public function getName() {
		return self::NAME . ' for ' . $this->getInput('searchUsername');
	}

	public function getURI() {
		return self::URI . '/user/' . $this->getInput('searchUsername');
	}
}