Re-worked Episode algorithmn to 30 minute blocks with commercials proceeding to fill time. More episode, less commercial.

This commit is contained in:
h264 2023-11-07 02:12:07 -05:00
parent d14b68451c
commit 69736c1361
2 changed files with 47 additions and 53 deletions

View File

@ -13,7 +13,7 @@ while(true); do
python $pyscript python $pyscript
DISPLAY=:0 cvlc --fullscreen --play-and-exit --sub-source logo --logo-position 10 --logo-opacity=128 --logo-file $buglocation --no-osd $playlist clear
DISPLAY=:0 cvlc -q --fullscreen --play-and-exit --sub-source logo --logo-position 10 --logo-opacity=128 --logo-file $buglocation --no-osd $playlist 2> /dev/null
done done

View File

@ -15,7 +15,7 @@ commercials = "/media/zella/anime/commercials"
#the "station id" video that calls out what the channel is. have fun with it. #the "station id" video that calls out what the channel is. have fun with it.
stationID = "/media/zella/anime/stationid/AAEAStationID.mp4" stationID = "/media/zella/anime/stationid/AAEAStationID.mp4"
secondsInHour = 3600 secondsInBlock = 1800
episodeBlockTime = 1560 episodeBlockTime = 1560
minimumTime = 30 minimumTime = 30
@ -123,25 +123,21 @@ print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
episodesEmptyFlag = False episodesEmptyFlag = False
firstLoop = True firstLoop = True
while not episodesEmptyFlag: while not episodesEmptyFlag:
#generate next episode block (station id + episode + fill in any extra time with commercial spots)
if firstLoop: if firstLoop:
timeLeft = get_remaining_seconds_in_hour() timeLeft = get_remaining_seconds_in_hour()
if timeLeft > secondsInBlock:
timeLeft -= secondsInBlock; # only use the extra time over the first half hour on the opening block
firstLoop = False firstLoop = False
else: else:
timeLeft = secondsInHour timeLeft = secondsInBlock
random.shuffle(showNumberList) random.shuffle(showNumberList)
showNumberListCount = 0 showNumberListCount = 0
while timeLeft > minimumTime: if timeLeft >= episodeBlockTime: #while there is time left in the 30 minute block
if timeLeft >= episodeBlockTime:
print("Enough time for an episode block")
#add station id #add station id
timeLeft -= get_video_length_in_seconds(stationID) timeLeft -= get_video_length_in_seconds(stationID)
playlist.write(stationID + "\n") playlist.write(stationID + "\n")
#add commercial. Maybe add a while loop here to add multiple commercials if one is too short
nextAd = get_next_commercial()
timeLeft -= get_video_length_in_seconds(nextAd)
playlist.write(nextAd + "\n")
#add tv episode #add tv episode
nextEpisode = "" nextEpisode = ""
while showNumberListCount < len(showNumberList): while showNumberListCount < len(showNumberList):
@ -154,39 +150,37 @@ while not episodesEmptyFlag:
timeLeft -= get_video_length_in_seconds(nextEpisode) timeLeft -= get_video_length_in_seconds(nextEpisode)
playlist.write(nextEpisode + "\n") playlist.write(nextEpisode + "\n")
print("\nEpisode " + nextEpisode + " added to playlist. " + str(len(lineupStack[showNumberList[showNumberListCount - 1]])) + " episodes left in stack\n") print("\nEpisode " + nextEpisode + " added to playlist. " + str(len(lineupStack[showNumberList[showNumberListCount - 1]])) + " episodes left in stack\n")
break break
if nextEpisode is None: if nextEpisode is None:
print("Episodes exhausted! Completing Playlist!\n") print("Episodes exhausted! Completing Playlist!\n")
episodesEmptyFlag = True episodesEmptyFlag = True
break break
#add commercial. #add commercial.
while timeLeft > minimumTime:
nextAd = get_next_commercial() nextAd = get_next_commercial()
timeLeft -= get_video_length_in_seconds(nextAd) comLength = get_video_length_in_seconds(nextAd)
playlist.write(nextAd + "\n") if timeLeft > comLength:
timeLeft -= comLength
#add commercial.
nextAd = get_next_commercial()
timeLeft -= get_video_length_in_seconds(nextAd)
playlist.write(nextAd + "\n") playlist.write(nextAd + "\n")
print("\nCommercial " + nextAd + " added to playlist.\n")
else:
print("\nCommercial too long. retrying...\n")
else: else:
#no time for furtur episodes this hour #no time for furtur episodes this hour
print("Not enough time for another episode this hour. Padding") print("Not enough time for another episode this hour. Padding")
#add station id
timeLeft -= get_video_length_in_seconds(stationID)
playlist.write(stationID + "\n")
#add commercial. #add commercial.
while timeLeft > minimumTime:
nextAd = get_next_commercial() nextAd = get_next_commercial()
timeLeft -= get_video_length_in_seconds(nextAd) comLength = get_video_length_in_seconds(nextAd)
playlist.write(nextAd + "\n") if timeLeft > comLength:
timeLeft -= comLength
#add commercial.
nextAd = get_next_commercial()
timeLeft -= get_video_length_in_seconds(nextAd)
playlist.write(nextAd + "\n") playlist.write(nextAd + "\n")
print("\nCommercial " + nextAd + " added to playlist.\n")
else:
print("\nCommercial too long. retrying...\n")
print("playlist file creation complete") print("playlist file creation complete")