def test_copy_file_to_destination(config, test_folder):
    source_file = test_folder.join('output.mp3')
    source_file.write('')
    source = str(source_file)
    target = str(test_folder.join('mystation', 'myshow', 'myepisode.pm3'))
    recorder = Recorder()
    recorder._copy_file_to_destination(source, target)
    assert os.path.exists(target)
    assert os.path.isfile(target)
Beispiel #2
0
def test_copy_file_to_destination(config, test_folder):
    source_file = test_folder.join('output.mp3')
    source_file.write('')
    source = str(source_file)
    target = str(test_folder.join('mystation', 'myshow', 'myepisode.pm3'))
    recorder = Recorder()
    recorder._copy_file_to_destination(source, target)
    assert os.path.exists(target)
    assert os.path.isfile(target)
Beispiel #3
0
def test_add_metadata(config, test_folder):
    import time
    media_file = test_folder.join('mystation', 'myshow', 'myepisode.pm3')
    station = config.stations['dlf']
    show = Show(station, 'me', 'Me', 2)
    recorder = Recorder()
    recorder.start_time = time.time()
    recorder._copy_file_to_destination(
        os.path.join(os.path.dirname(__file__), 'testfile.mp3'),
        str(media_file))
    recorder._add_metadata(show, str(media_file))
    try:
        # Python 2.x
        from mutagen.mp3 import MP3
    except ImportError:
        # Python 3.x
        from mutagenx.mp3 import MP3

    audio = MP3(str(media_file))
    #assert 'tit' == audio['TIT2'].text[0]
    assert 'Podcast' == audio['TCON'].text[0]
    assert 'Deutschlandfunk' == audio['TPE1'].text[0]
    assert 'Deutschlandfunk' == audio['TCOP'].text[0]
    assert 'Me' == audio['TALB'].text[0]
    assert 'http://example.org/dlf' == audio['TCOM'].text[0]
    assert u'2000' == audio['TLEN'].text[0]
Beispiel #4
0
def test_add_metadata(config, test_folder):
    import shutil
    from mutagenx.mp3 import MP3

    media_file = test_folder.join('mystation', 'myshow', 'myepisode.pm3')
    os.makedirs(os.path.dirname(str(media_file)))
    shutil.copy(os.path.join(os.path.dirname(__file__), 'testfile.mp3'), str(media_file))

    station = config.stations['dlf']
    show = Show(config, station, 'me', 'Me', 2)
    episode = Episode(config, show)
    episode.filename = str(media_file)
    recorder = Recorder()
    recorder._add_metadata(episode)

    audio = MP3(str(media_file))
    #assert 'tit' == audio['TIT2'].text[0]
    assert 'Podcast' == audio['TCON'].text[0]
    assert 'Deutschlandfunk' == audio['TPE1'].text[0]
    assert 'Deutschlandfunk' == audio['TCOP'].text[0]
    assert 'Me' == audio['TALB'].text[0]
    assert 'http://example.org/dlf' == audio['TCOM'].text[0]
    assert u'2000' == audio['TLEN'].text[0]
Beispiel #5
0
def test_add_metadata(config, test_folder):
    import shutil
    from mutagenx.mp3 import MP3

    media_file = test_folder.join('mystation', 'myshow', 'myepisode.pm3')
    os.makedirs(os.path.dirname(str(media_file)))
    shutil.copy(os.path.join(os.path.dirname(__file__), 'testfile.mp3'), str(media_file))

    station = config.stations['dlf']
    show = Show(config, station, 'me', 'Me', 2)
    episode = Episode(config, show)
    episode.filename = str(media_file)
    recorder = Recorder()
    recorder._add_metadata(episode)

    audio = MP3(str(media_file))
    #assert 'tit' == audio['TIT2'].text[0]
    assert 'Podcast' == audio['TCON'].text[0]
    assert 'Deutschlandfunk' == audio['TPE1'].text[0]
    assert 'Deutschlandfunk' == audio['TCOP'].text[0]
    assert 'Me' == audio['TALB'].text[0]
    assert 'http://example.org/dlf' == audio['TCOM'].text[0]
    assert u'2000' == audio['TLEN'].text[0]
def test_add_metadata(config, test_folder):
    import time
    media_file = test_folder.join('mystation', 'myshow', 'myepisode.pm3')
    station = config.stations['dlf']
    show = Show(station, 'me', 'Me', 2)
    recorder = Recorder()
    recorder.start_time = time.time()
    recorder._copy_file_to_destination(os.path.join(os.path.dirname(__file__), 'testfile.mp3'), str(media_file))
    recorder._add_metadata(show, str(media_file))
    try:
        # Python 2.x
        from mutagen.mp3 import MP3
    except ImportError:
        # Python 3.x
        from mutagenx.mp3 import MP3

    audio = MP3(str(media_file))
    #assert 'tit' == audio['TIT2'].text[0]
    assert 'Podcast' == audio['TCON'].text[0]
    assert 'Deutschlandfunk' == audio['TPE1'].text[0]
    assert 'Deutschlandfunk' == audio['TCOP'].text[0]
    assert 'Me' == audio['TALB'].text[0]
    assert 'http://example.org/dlf' == audio['TCOM'].text[0]
    assert u'2000' == audio['TLEN'].text[0]
Beispiel #7
0
def test_old_style_configuration(test_folder):
    test_folder.join('capturadiorc.oldstyle').write('''[settings]
destination = {0}/demodata
date_pattern = %d.%m.%Y %H:%M

[stations]
dlf = http://example.org/dlf
dkultur = http://example.org/dkultur
wdr2 =  http://example.org/wdr2

; settings for the Podcast feed
[feed]
url = http://my.example.org
title = Internet Radio Recordings
about_url = http://my.example.org/about.html
description = Recordings
language = en
filename = rss.xml
default_logo_url = http://example.org/default.png
default_logo_copyright = A Creative Commons license

; additional settings for station 'dlf'
[dlf]
name = Deutschlandfunk
link_url = http://example.org/dlf
logo_url = http://example.org/dlf.png
shows = nachtradio  weather

; Settings for the show "Nachtradio" on station "dlf"
[nachtradio]
title = Nachtradio
duration = 3300
link_url = http://example.org/nachtradio
logo_url = http://example.org/nachtradio.png

[weather]
title = Weather forecast
duration = 300
logo_url = http://example.org/weather.png

[wdr2]
title = WDR 2
link_url = http://example.org/wdr2
logo_url = http://example.org/wdr2.png
shows = news

[news]
title = Latest news
duration = 300
link_url = http://example.org/wdr2/news
logo_url = http://example.org/wdr2/news.png
'''.format(str(test_folder)))

    test_folder.join('capturadiorc.newstyle').write('''[settings]
destination = {0}/demodata
date_pattern = %d.%m.%Y %H:%M

[stations]
dlf = http://example.org/dlf
dkultur = http://example.org/dkultur
wdr2 = http://example.org/wdr2

[feed]
title = Internet Radio Recordings
about_url = http://my.example.org/about.html
description = Recordings
language = en
filename = rss.xml
default_logo_url = http://example.org/default.png
default_logo_copyright = A Creative Commons license
base_url = http://my.example.org

[dlf]
name = Deutschlandfunk
link_url = http://example.org/dlf
logo_url = http://example.org/dlf.png

[nachtradio]
title = Nachtradio
duration = 3300
link_url = http://example.org/nachtradio
logo_url = http://example.org/nachtradio.png
station = dlf

[weather]
title = Weather forecast
duration = 300
logo_url = http://example.org/weather.png
station = dlf

[wdr2]
title = WDR 2
link_url = http://example.org/wdr2
logo_url = http://example.org/wdr2.png

[news]
title = Latest news
duration = 300
link_url = http://example.org/wdr2/news
logo_url = http://example.org/wdr2/news.png
station = wdr2

'''.format(str(test_folder)))

    configuration = Configuration(folder=str(test_folder),
                                  filename='capturadiorc.oldstyle',
                                  reset=True)
    assert configuration.filename == os.path.join(configuration.folder,
                                                  'capturadiorc.oldstyle')
    assert Configuration.changed_settings is True
    assert os.path.exists(configuration.filename)
    assert os.path.exists(configuration.filename + '.bak')
    import filecmp
    assert filecmp.cmp(
        os.path.join(configuration.folder, 'capturadiorc.oldstyle'),
        os.path.join(configuration.folder, 'capturadiorc.newstyle'))
Beispiel #8
0
def test_old_style_configuration(test_folder):
    test_folder.join('capturadiorc.oldstyle').write('''[settings]
destination = {0}/demodata ; path relative to runtime dir
date_pattern = %d.%m.%Y %H:%M

[stations]
dlf = http://example.org/dlf
dkultur = http://example.org/dkultur
wdr2 =  http://example.org/wdr2

; settings for the Podcast feed
[feed]
url = http://my.example.org
title = Internet Radio Recordings
about_url = http://my.example.org/about.html
description = Recordings
language = en
filename = rss.xml
default_logo_url = http://example.org/default.png
default_logo_copyright = A Creative Commons license

; additional settings for station 'dlf'
[dlf]
name = Deutschlandfunk
link_url = http://example.org/dlf
logo_url = http://example.org/dlf.png
shows = nachtradio  weather

; Settings for the show "Nachtradio" on station "dlf"
[nachtradio]
title = Nachtradio
duration = 3300
link_url = http://example.org/nachtradio
logo_url = http://example.org/nachtradio.png

[weather]
title = Weather forecast
duration = 300
logo_url = http://example.org/weather.png

[wdr2]
title = WDR 2
link_url = http://example.org/wdr2
logo_url = http://example.org/wdr2.png
shows = news

[news]
title = Latest news
duration = 300
link_url = http://example.org/wdr2/news
logo_url = http://example.org/wdr2/news.png
'''.format(str(test_folder)))

    test_folder.join('capturadiorc.newstyle').write('''[settings]
destination = {0}/demodata
date_pattern = %d.%m.%Y %H:%M

[stations]
dlf = http://example.org/dlf
dkultur = http://example.org/dkultur
wdr2 = http://example.org/wdr2

[feed]
base_url = http://my.example.org
title = Internet Radio Recordings
about_url = http://my.example.org/about.html
description = Recordings
language = en
filename = rss.xml
default_logo_url = http://example.org/default.png
default_logo_copyright = A Creative Commons license

[dlf]
name = Deutschlandfunk
link_url = http://example.org/dlf
logo_url = http://example.org/dlf.png

[nachtradio]
title = Nachtradio
duration = 3300
link_url = http://example.org/nachtradio
logo_url = http://example.org/nachtradio.png
station = dlf

[weather]
title = Weather forecast
duration = 300
logo_url = http://example.org/weather.png
station = dlf

[wdr2]
title = WDR 2
link_url = http://example.org/wdr2
logo_url = http://example.org/wdr2.png

[news]
title = Latest news
duration = 300
link_url = http://example.org/wdr2/news
logo_url = http://example.org/wdr2/news.png
station = wdr2

'''.format(str(test_folder)))

    configuration = Configuration(
        folder=str(test_folder),
        filename='capturadiorc.oldstyle',
        reset=True
    )
    assert configuration.filename == os.path.join(
        configuration.folder,
        'capturadiorc.oldstyle'
    )
    assert Configuration.changed_settings is True
    assert os.path.exists(configuration.filename)
    assert os.path.exists(configuration.filename + '.bak')
    import filecmp
    assert filecmp.cmp(
        os.path.join(configuration.folder, 'capturadiorc.oldstyle'),
        os.path.join(configuration.folder, 'capturadiorc.newstyle')
    )