Add play to song play count.

		Parameters:
			song (dict): A song dict.

		Returns:
			bool: ``True`` if successful, ``False`` if not.
549010
def song_play(self, song):
		

		if 'storeId' in song:
			song_id = song['storeId']
		elif 'trackId' in song:
			song_id = song['trackId']
		else:
			song_id = song['id']

		song_duration = song['durationMillis']

		event = mc_calls.ActivityRecordRealtime.play(song_id, song_duration)
		response = self._call(
			mc_calls.ActivityRecordRealtime,
			event
		)

		return True if response.body['eventResults'][0]['code'] == 'OK' else False
1342386
def song(self, song_id):
		

		if song_id.startswith('T'):
			song_info = self._call(
				mc_calls.FetchTrack,
				song_id
			).body
		else:
			song_info = next(
				(
					song
					for song in self.songs()
					if song['id'] == song_id
				),
				None
			)

		return song_info
177845
function addTrackToNewPlaylist(options) {
    return new Promise(function (resolve, reject) {
        var form = new FormData();
        form.append('format', 'json');

        if (!options.tracks) {
            return reject('Error while addTrackToNewPlaylist options.tracks is null');
        } else {
            _.each(options.tracks, function (track) {
                form.append('playlist[tracks][][id]', track.id);
            });
        }
        if (!options.title) {
            return reject('Error while addTrackToNewPlaylist options.title is null');
        } else {
            form.append('playlist[title]', options.title);
        }
        if (!options.sharing) {
            return reject('Error while addTrackToNewPlaylist options.sharing is null');
        } else {
            form.append('playlist[sharing]', options.sharing);
        }
        if (!options.oauth_token) {
            return reject('Error while addTrackToNewPlaylist options.oauth_token is null');
        } else {
            form.append('oauth_token', options.oauth_token);
        }

        form.getLength(function (err, length) {

            fetch(`https://api.soundcloud.com/playlists?oauth_token=${options.oauth_token}`, {
                method: 'POST',
                body: form,
                headers: {'content-length': length}
            }).then(function (res) {

                if (res.status === 201) {
                    if (DEBUG_MODE_ON) {
                        console.log(`INFO: addTrackToNewPlaylist, OK -> ${res.statusCode}.`);
                    }
                    return res.json();
                } else {
                    return null;
                }
            }).then(function (json) {
                if (!json) {
                    reject();
                } else {
                    if (DEBUG_MODE_ON) {
                        console.log('INFO: addTrack successful');
                    }
                    resolve(json);
                }
            }).catch(function (e) {
                reject(e);
            });

        });
    });
}
425224
def get_song(self, id_):
        """"""
        endpoint = "songs/{id}".format(id=id_)
        return self._make_request(endpoint)
951587
def cmd_playtune(self, args):
        ''''''
        if len(args) < 1:
            print("Usage: playtune TUNE")
            return
        tune = args[0]
        str1 = tune[0:30]
        str2 = tune[30:]
        if sys.version_info.major >= 3 and not isinstance(str1, bytes):
            str1 = bytes(str1, "ascii")
        if sys.version_info.major >= 3 and not isinstance(str2, bytes):
            str2 = bytes(str2, "ascii")
        self.master.mav.play_tune_send(self.settings.target_system,
                                       self.settings.target_component,
                                       str1, str2)
200276
def download_playlist_by_id(self, playlist_id, playlist_name):
        

        try:
            songs = self.crawler.get_playlist_songs(
                playlist_id)
        except RequestException as exception:
            click.echo(exception)
        else:
            folder = os.path.join(self.folder, playlist_name)
            for song in songs:
                self.download_song_by_id(song.song_id, song.song_name, folder)
1364839
def get_playcount(self):
        """"""

        doc = self._request(self.ws_prefix + ".getInfo", True)

        return _number(_extract(doc, "playcount"))
418733
function canPlayTypeToNumber(playability) {
	if (playability === 'probably') {
		return 2;
	} else if (playability === 'maybe') {
		return 1;
	} else if (playability === '') {
		return 0;
	} else if (typeof playability === 'string') {
		throw new Error('Expected a string "probably", "maybe" or "" but received ' + playability + '.');
	}

	throw new TypeError(String(playability) + ' is not a string. Expected a string "probably", "maybe" or "".');
}
385063
def scrobble_many(self, tracks):
        

        tracks_to_scrobble = tracks[:50]
        if len(tracks) > 50:
            remaining_tracks = tracks[50:]
        else:
            remaining_tracks = None

        params = {}
        for i in range(len(tracks_to_scrobble)):

            params["artist[%d]" % i] = tracks_to_scrobble[i]["artist"]
            params["track[%d]" % i] = tracks_to_scrobble[i]["title"]

            additional_args = (
                "timestamp",
                "album",
                "album_artist",
                "context",
                "stream_id",
                "track_number",
                "mbid",
                "duration",
            )
            args_map_to = {  # so friggin lazy
                "album_artist": "albumArtist",
                "track_number": "trackNumber",
                "stream_id": "streamID",
            }

            for arg in additional_args:

                if arg in tracks_to_scrobble[i] and tracks_to_scrobble[i][arg]:
                    if arg in args_map_to:
                        maps_to = args_map_to[arg]
                    else:
                        maps_to = arg

                    params["%s[%d]" % (maps_to, i)] = tracks_to_scrobble[i][arg]

        _Request(self, "track.scrobble", params).execute()

        if remaining_tracks:
            self.scrobble_many(remaining_tracks)
952616
def playlist(self, playlist_id, *, include_songs=False):
		

		playlist_info = next(
			(
				playlist
				for playlist in self.playlists(include_songs=include_songs)
				if playlist['id'] == playlist_id
			),
			None
		)

		return playlist_info
896790
def _play(self):
        
        while True:
            if self._buffered:
                self._source.push(self._buffer.get())
165689
def play_track(self, track_id=DEFAULT_TRACK_ID, position=0):
        """"""
        self.publish(
            action='playTrack',
            resource='audioPlayback/player',
            publish_response=False,
            properties={'trackId': track_id, 'position': position}
        )
790139
def download(self, song):
		

		song_id = song['id']

		response = self._call(
			mm_calls.Export,
			self.uploader_id,
			song_id)
		audio = response.body
		suggested_filename = unquote(
			response.headers['Content-Disposition'].split("filename*=UTF-8''")[-1]
		)

		return (audio, suggested_filename)
605866
def play(self, sound):
        
        self.is_done.clear()  # hold is_done until the sound is played
        if self.sr != sound.sr:
            raise ValueError('You can only play sound with a samplerate of {} (here {}). Use the Sound.resample method for instance.', self.sr, sound.sr)

        if sound in self.sounds:
            self.remove(sound)

        with self.chunk_available:
            self.sounds.append(sound)
            sound.playing = True

            self.chunk_available.notify()
        self.is_done.wait()
805511
def songname(song_name):
    '''
    
    '''
    try:
        song_name = splitext(song_name)[0]
    except IndexError:
        pass

    # Words to omit from song title for better results through spotify's API
    chars_filter = "()[]{}-:_/=+\"\'"
    words_filter = ('official', 'lyrics', 'audio', 'remixed', 'remix', 'video',
                    'full', 'version', 'music', 'mp3', 'hd', 'hq', 'uploaded')

    # Replace characters to filter with spaces
    song_name = ''.join(map(lambda c: " " if c in chars_filter else c, song_name))

    # Remove crap words
    song_name = re.sub('|'.join(re.escape(key) for key in words_filter),
                       "", song_name, flags=re.IGNORECASE)

    # Remove duplicate spaces
    song_name = re.sub(' +', ' ', song_name)
    return song_name.strip()
1004691
async def songs(self):
    '''
    '''
    items = []
    for i in await self.items:
      if i.type == 'Audio':
        items.append(i)
      elif hasattr(i, 'songs'):
        items.extend(await i.songs)
    return items
392910
def search_song(self, song_name, quiet=False, limit=9):
        

        result = self.search(song_name, search_type=1, limit=limit)

        if result['result']['songCount'] <= 0:
            LOG.warning('Song %s not existed!', song_name)
            raise SearchNotFound('Song {} not existed.'.format(song_name))
        else:
            songs = result['result']['songs']
            if quiet:
                song_id, song_name = songs[0]['id'], songs[0]['name']
                song = Song(song_id, song_name)
                return song
            else:
                return self.display.select_one_song(songs)