<commit_before>'use strict';

Connector.playerSelector = '#plex';

Connector.artistSelector = '.grandparent-title';

Connector.trackSelector = '.title-container .item-title';

Connector.currentTimeSelector = '.player-position';

Connector.durationSelector = '.player-duration';

Connector.isPlaying = () => $('.player .play-btn').hasClass('hidden');

Connector.getTrackArt = () => $('.player .media-poster').data('imageUrl');

Connector.getAlbum = () => $('.player .media-poster').data('parentTitle');<commit_msg>Improve PLEX connector<commit_after>'use strict';

setupConnector();

/**
 * Setup properties.
 */
function setupConnector() {
	if (isRemoteUI()) {
		setupRemoteUI();
	} else {
		setupLocalUI();
	}
}

/**
 * Check if remote UI is used.
 * @return {Boolean} Check result
 */
function isRemoteUI() {
	return location.hostname === 'app.plex.tv';
}

/**
 * Setup properties for UI available on http://127.0.x.x:xxxxx.
 */
function setupLocalUI() {
	Connector.playerSelector = '#plex';

	Connector.artistSelector = '.grandparent-title';

	Connector.trackSelector = '.title-container .item-title';

	Connector.currentTimeSelector = '.player-position';

	Connector.durationSelector = '.player-duration';

	Connector.isPlaying = () => $('.player .play-btn').hasClass('hidden');

	Connector.getTrackArt = () => $('.player .media-poster').data('imageUrl');

	Connector.getAlbum = () => $('.player .media-poster').data('parentTitle');
}

/**
 * Setup properties for UI available on https://app.plex.tv/web/app.
 */
function setupRemoteUI() {
	Connector.playerSelector = '[class^=MiniPlayerContainer-miniPlayer]';

	Connector.artistSelector = `${Connector.playerSelector} [class*=MetadataPosterTitle-title] > a:nth-child(1)`;

	Connector.trackSelector = `${Connector.playerSelector} [class*=titlesContainer] > a`;

	Connector.albumSelector = `${Connector.playerSelector} [class*=MetadataPosterTitle-title] > a:nth-child(3)`;

	Connector.playButtonSelector = `${Connector.playerSelector} [class^=plex-icon-player-play]`;

	Connector.timeInfoSelector = `${Connector.playerSelector} [class^=DurationRemaining-container]`;
}
{'fraction_non_alphanumeric': 0.18104667609618105, 'fraction_numerical': 0.002828854314002829, 'mean_word_length': 5.372372372372372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, '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': '3781569', 'n_tokens_mistral': 658, 'n_tokens_neox': 659, 'n_words': 108}