#!/usr/bin/python
# -*- coding: utf-8 -*-

import random
import subprocess


# URLs from different places:
# - https://www.nps.gov/romo/learn/photosmultimedia/sounds-ambient-soundscapes.htm
# - https://www.nps.gov/yell/learn/photosmultimedia/sounds-soundscapes.htm
# - https://www.nps.gov/havo/learn/nature/dawn-chorus.htm
# - https://www.youtube.com/user/VoicesintheValley/videos (linked from https://www.nps.gov/articles/soundsofspring.htm)
SOUNDS = [
    ["Dawn Soundscape from Big Meadows, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-DawnAmbientROMO6816BigMeadowsFinal1.mp3"],
    ["Dawn Wetland Soundscape from Moraine Park, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-MoraineWetlandAmbientROMO51816Final1.mp3"],
    ["Dawn Soundscape from the Sun Valley Trail, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-DawnAmbientROMO6916SunValleyTrailFinal1.mp3"],
    ["Morning Soundscape from Finch Lake, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-FinchLakeAmbientROMO62016Final1.mp3"],
    ["Evening Soundscape from Moraine Park, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-MoraineParkAmbient51916Final1.mp3"],
    ["Stream Soundscape from the Black Canyon Trail, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-StreamAmbientROMO52516BlackCanyonTrailFinal1.mp3"],
    ["Forest Soundscape from Lawn Lake, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-ForestAmbientNearLawnLakeROMO52616Final1.mp3"],
    ["Tundra Soundscape from Medicine Bow Trailhead, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-TundraAmbientROMO6916MedicineBowTrailFinal1.mp3"],
    ["Wind Soundscape from Gem Lake, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-WindAmbientGemLakeROMO52516Final1.mp3"],
    ["Thunderstorm Soundscape from Hollowell Park, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-ThunderstormROMO662017HollowellPark1.mp3"],
    ["Thunderstorm Soundscape from the Black Canyon Trail, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-ThunderstormAmbientROMO52616BlackCanyonTrail1.mp3"],
    ["Thunderstorm Soundscape from the Sunrise Campsite, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-ThunderstormAmbientROMO6716SunriseSite2Final.mp3"],
    ["Thunderstorm, Rain and Hail Soundscape from the Sunrise Campsite, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-ThunderstormAmbientROMO6716SunriseSiteFinalwav.mp3"],
    ["Western Chorus Frogs in Moraine Park, Rocky Mountain National Park", "https://www.nps.gov/av/imr/avElement/romo-MoraineParkWesternchorusfrogsROMO51916Final.mp3"],
    ["Dawn Chorus at Kīpuka Kī, Hawai'i Volcanoes National Park", "https://www.nps.gov/av/pwr/avElement/havo-KipukaKi20150514.mp3"],
    ["Spring Peepers and Pickerel Frogs, Cuyahoga Valley National Park", "https://www.youtube.com/watch?v=tN9vWd0aJPw"],
    ["Bullfrog, Green frog and Gray treefrog, Cuyahoga Valley National Park", "https://www.youtube.com/watch?v=cpNBVvwWofc"],
    ["Gray Treefrog (Hyla versicolor) chorus and approaching thunderstorm, Cuyahoga Valley National Park", "https://www.youtube.com/watch?v=c2xVJPmcOk4"],
    ["American Toad (Bufo americanus), Cuyahoga Valley National Park", "https://www.youtube.com/watch?v=OdOVMFNqJjY"],
    ["Midland Chorus Frog chorus, Cuyahoga Valley National Park", "https://www.youtube.com/watch?v=PDLv-aJp58c"],
    ["Midland Chorus frogs with Coyotes calling, Cuyahoga Valley National Park", "https://www.youtube.com/watch?v=iUfSwquIzzU"],
    ["Geyser Hill, Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-030401GeyserHillStreamOffBoardwalkBackgroundGeyserRumblesAndWindBinaural0101.mp3"],
    ["Geyser Hill (birds), Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-030402GeyserHillNearSulphideSpringBirdsBinaural0101.mp3"],
    ["Lower Geyser Basin (Strong Wind), Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-040201LowerGeyserBasinWindInTreesBinaural01011.mp3"],
    ["Yellowstone Lake, Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-YELLLakeSoundscape20160914T14ms.mp3"],
    ["Raft of Birds at Chipmunk Creek, Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-YELLLakeSoundscape20160914T06ms.mp3"],
    ["September Sounds at Chipmunk Creek, Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-YELLLakeSoundscape20160914T05ms.mp3"],
    ["September Sounds at Chipmunk Creek (second take), Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-YELLLakeSoundscape20160914T03ms.mp3"],
    ["Common Loon Wailing at lake, Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-YELLLakeSoundscape20160914T001ms.mp3"],
    ["Shores of Peale Island at Yellowstone Lake, Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-YELLLakeSoundscape20160913T01ms.mp3"],
    ["Bull Elk Bugling at Yellowstone Lake, Yellowstone National Park", "https://www.nps.gov/av/imr/avElement/yell-YELLLakeElkRut20160913T004ms.mp3"],
]


def main():
    proc = None
    while True:
        try:
            title, url = random.choice(SOUNDS)
            print("Now playing %s" % title)
            proc = subprocess.Popen("mpv --really-quiet --no-video %s" % url, shell=True)
            proc.wait()
        except KeyboardInterrupt:
            break

    proc.terminate()
    print("Bye!")


if __name__ == '__main__':
    main()
