import logging


def incrementSeason(mediaInfoRecords, queryMediaInfoRecord):
	"""
	incrementSeason takes a set of mediaInfoRecords finds the one that matches the queryMediaInfoRecord and increments the season number
	:testedWith: TestMediaIndexFileInterface:test_incrementSeason
	:param mediaInfoRecords: the set of MediaInfoRecord's, one of which should be updated
	:param queryMediaInfoRecord: the relevant MediaInfoRecord that corresponds to the record that should be updated
	:return: None if the queryMediaInfoRecord could not be found, the set of updated mediaInfoRecords if it can
	"""

	for mediaInfoRecord in mediaInfoRecords:
		if mediaInfoRecord.getShowName() == queryMediaInfoRecord.getShowName():
			prevSeasonValue = mediaInfoRecord.getLatestSeasonNumber()

			mediaInfoRecord.setLatestSeasonNumber(prevSeasonValue + 1)
			mediaInfoRecord.setLatestEpisodeNumber(1)
			logging.info(
				f"Updated latest season number from {prevSeasonValue} to {mediaInfoRecord.getLatestSeasonNumber()}")

			return mediaInfoRecords
	return None