<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stream_url(self, item, *, device_id=None, quality='hi', session_token=None):
 		"""Get a URL to stream a podcast episode, library song, station_song, or store song. 		Note: 			Streaming requires a ``device_id`` from a valid, linked mobile device. 		Parameters: 			item (str):
 A podcast episode, library song, station_song, or store song. 				A Google Music subscription is required to stream store songs. 			device_id (str, Optional):
 A mobile device ID. 				Default: Use ``device_id`` of the :class:`MobileClient` instance. 			quality (str, Optional):
 Stream quality is one of ``'hi'`` (320Kbps), ``'med'`` (160Kbps), or ``'low'`` (128Kbps). 				Default: ``'hi'``. 			session_token (str):
 Session token from a station dict required for unsubscribed users to stream a station song. 				station['sessionToken'] as returend by :meth:`station` only exists for free accounts. 		Returns: 			str: A URL to an MP3 file. 		"""


		if device_id is None:
			device_id = self.device_id

		if 'episodeId' in item:  # Podcast episode.
			response = self._call(
				mc_calls.PodcastEpisodeStreamURL,
				item['episodeId'],
				quality=quality,
				device_id=device_id
			)
		elif 'wentryid' in item:  # Free account station song.
			response = self._call(
				mc_calls.RadioStationTrackStreamURL,
				item['storeId'],
				item['wentryid'],
				session_token,
				quality=quality,
				device_id=device_id
			)
		elif 'trackId' in item:  # Playlist song.
			response = self._call(
				mc_calls.TrackStreamURL,
				item['trackId'],
				quality=quality,
				device_id=device_id
			)
		elif 'storeId' in item and self.is_subscribed:  # Store song.
			response = self._call(
				mc_calls.TrackStreamURL,
				item['storeId'],
				quality=quality,
				device_id=device_id
			)
		elif 'id' in item:  # Library song.
			response = self._call(
				mc_calls.TrackStreamURL,
				item['id'],
				quality=quality,
				device_id=device_id
			)
		else:
			# TODO: Create an exception for not being subscribed or use a better builtin exception for this case.
			if 'storeId' in item and not self.is_subscribed:
				msg = "Can't stream a store song without a subscription."
			else:
				msg = "Item does not contain an ID field."

			raise ValueError(msg)

		try:
			stream_url = response.headers['Location']
		except KeyError:
			stream_url = response.body['url']

		return stream_url