<commit_before><?php
class SoundCloudBridge extends BridgeAbstract {

	const MAINTAINER = 'kranack';
	const NAME = 'Soundcloud Bridge';
	const URI = 'https://soundcloud.com/';
	const CACHE_TIMEOUT = 600; // 10min
	const DESCRIPTION = 'Returns 10 newest music from user profile';

	const PARAMETERS = array( array(
		'u' => array(
			'name' => 'username',
			'required' => true
		)
	));

	const CLIENT_ID = 'W0KEWWILAjDiRH89X0jpwzuq6rbSK08R';

	public function collectData(){

		$res = json_decode(getContents(
			'https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'
			. urlencode($this->getInput('u'))
			. '&client_id='
			. self::CLIENT_ID
		)) or returnServerError('No results for this query');

		$tracks = json_decode(getContents(
			'https://api.soundcloud.com/users/'
			. urlencode($res->id)
			. '/tracks?client_id='
			. self::CLIENT_ID
		)) or returnServerError('No results for this user');

		$numTracks = min(count($tracks), 10);
		for($i = 0; $i < $numTracks; $i++) {
			$item = array();
			$item['author'] = $tracks[$i]->user->username;
			$item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title;
			$item['timestamp'] = strtotime($tracks[$i]->created_at);
			$item['content'] = $tracks[$i]->description;
			$item['enclosures'] = array($tracks[$i]->uri
			. '/stream?client_id='
			. self::CLIENT_ID);

			$item['id'] = self::URI
				. urlencode($this->getInput('u'))
				. '/'
				. urlencode($tracks[$i]->permalink);
			$item['uri'] = self::URI
				. urlencode($this->getInput('u'))
				. '/'
				. urlencode($tracks[$i]->permalink);
			$this->items[] = $item;
		}

	}

	public function getName(){
		if(!is_null($this->getInput('u'))) {
			return self::NAME . ' - ' . $this->getInput('u');
		}

		return parent::getName();
	}
}<commit_msg>[SoundCloudBridge] Use account avatar as feed icon (#1146)<commit_after><?php
class SoundCloudBridge extends BridgeAbstract {

	const MAINTAINER = 'kranack';
	const NAME = 'Soundcloud Bridge';
	const URI = 'https://soundcloud.com/';
	const CACHE_TIMEOUT = 600; // 10min
	const DESCRIPTION = 'Returns 10 newest music from user profile';

	const PARAMETERS = array( array(
		'u' => array(
			'name' => 'username',
			'required' => true
		)
	));

	const CLIENT_ID = 'W0KEWWILAjDiRH89X0jpwzuq6rbSK08R';

	private $feedIcon = null;

	public function collectData(){

		$res = json_decode(getContents(
			'https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'
			. urlencode($this->getInput('u'))
			. '&client_id='
			. self::CLIENT_ID
		)) or returnServerError('No results for this query');

		$this->feedIcon = $res->avatar_url;

		$tracks = json_decode(getContents(
			'https://api.soundcloud.com/users/'
			. urlencode($res->id)
			. '/tracks?client_id='
			. self::CLIENT_ID
		)) or returnServerError('No results for this user');

		$numTracks = min(count($tracks), 10);
		for($i = 0; $i < $numTracks; $i++) {
			$item = array();
			$item['author'] = $tracks[$i]->user->username;
			$item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title;
			$item['timestamp'] = strtotime($tracks[$i]->created_at);
			$item['content'] = $tracks[$i]->description;
			$item['enclosures'] = array($tracks[$i]->uri
			. '/stream?client_id='
			. self::CLIENT_ID);

			$item['id'] = self::URI
				. urlencode($this->getInput('u'))
				. '/'
				. urlencode($tracks[$i]->permalink);
			$item['uri'] = self::URI
				. urlencode($this->getInput('u'))
				. '/'
				. urlencode($tracks[$i]->permalink);
			$this->items[] = $item;
		}

	}

	public function getIcon(){
		if ($this->feedIcon) {
			return $this->feedIcon;
		}

		return parent::getIcon();
	}

	public function getName(){
		if(!is_null($this->getInput('u'))) {
			return self::NAME . ' - ' . $this->getInput('u');
		}

		return parent::getName();
	}
}
{'fraction_non_alphanumeric': 0.20582830139144132, 'fraction_numerical': 0.009976371751115778, 'mean_word_length': 3.8045397225725095, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4795273', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1348, 'n_words': 241}