示例#1
0
def ui_factory_reset():
    # Get channel info
    form = ChannelForm(formdata=request.form)
    if request.method == 'POST':
        # Reset
        Controller.factory_reset()
        return redirect('/ui/home')
    return render_template('factory_reset.html')
示例#2
0
def ui_download_playlist(identifier):
    # Get playlist info
    playlist = Controller.get_playlist(identifier)

    if playlist:
        # Download playlist
        logs = Controller.download_playlist(identifier)
        return render_template('playlists/download_playlist.html', logs=logs,
                               id=playlist['id'],
                               name=playlist['name'],
                               youtube_id=playlist['youtube_id'],
                               uploader=playlist['uploader'])
示例#3
0
def ui_new_playlist():
    form = PlaylistForm(request.form)

    if request.method == 'POST' and form.validate():
        # Get form data
        class Args:
            url = form.url.data
            name = form.name.data

        # save the playlist
        Controller.new_playlist(Args())
        return redirect('/ui/playlists')

    return render_template('playlists/new_playlist.html', form=form)
示例#4
0
def ui_delete_channel(identifier):
    # Get channel info
    channel = Controller.get_channel(identifier)
    form = ChannelForm(formdata=request.form)

    if channel:
        if request.method == 'POST':
            # Delete channel
            Controller.delete_channel(identifier)
            return redirect('/ui/channels')
        return render_template('channels/delete_channel.html',
                               channel=channel['channel'],
                               separator=channel['separator'],
                               artist_before_title=channel['artist_before_title'])
示例#5
0
def ui_new_channel():
    form = ChannelForm(request.form)

    if request.method == 'POST' and form.validate():
        # Get form data
        class Args:
            channel = form.channel.data
            separator = form.separator.data
            artist_before_title = form.artist_before_title.data

        # save the channel
        Controller.new_channel(Args())
        return redirect('/ui/channels')

    return render_template('channels/new_channel.html', form=form)
示例#6
0
def ui_delete_playlist(identifier):
    # Get playlist info
    playlist = Controller.get_playlist(identifier)
    form = PlaylistForm(formdata=request.form)

    if playlist:
        if request.method == 'POST' and form.validate():
            # Delete playlist
            Controller.delete_playlist(identifier)
            return redirect('/ui/playlists')
        return render_template('playlists/delete_playlist.html',
                               id=playlist['id'],
                               name=playlist['name'],
                               youtube_id=playlist['youtube_id'],
                               uploader=playlist['uploader'])
示例#7
0
def ui_delete_naming_rule(identifier):
    # Get rule info
    naming_rule = Controller.get_naming_rule(identifier)
    form = NamingRuleForm(formdata=request.form)

    if naming_rule:
        if request.method == 'POST' and form.validate():
            # Delete rule
            Controller.delete_naming_rule(identifier)
            return redirect('/ui/naming-rules')
        return render_template('naming_rules/delete_naming_rule.html',
                               id=naming_rule['id'],
                               replace=naming_rule['replace'],
                               replace_by=naming_rule['replace_by'],
                               priority=naming_rule['priority'])
示例#8
0
def ui_new_naming_rule():
    form = NamingRuleForm(request.form)

    if request.method == 'POST' and form.validate():
        # Get form data
        class Args:
            replace = form.replace.data
            replace_by = form.replace_by.data
            priority = form.priority.data

        # save the rule
        Controller.new_naming_rule(Args())
        return redirect('/ui/naming-rules')

    return render_template('naming_rules/new_naming_rule.html', form=form)
示例#9
0
def ui_edit_channel(identifier):
    # Get channel info
    channel = Controller.get_channel(identifier)
    form = ChannelForm(formdata=request.form, separator=channel['separator'],
                       artist_before_title=channel['artist_before_title'])

    if channel:
        if request.method == 'POST' and form.validate():
            # save edits
            class Args:
                separator = form.separator.data
                artist_before_title = form.artist_before_title.data

            Controller.update_channel(identifier, Args())
            return redirect('/ui/channels')
        return render_template('channels/edit_channel.html', form=form, channel=channel['channel'])
示例#10
0
 def post(identifier):
     parser = reqparse.RequestParser()
     parser.add_argument('title', required=True)
     parser.add_argument('artist', required=True)
     parser.add_argument('new', required=True)
     args = parser.parse_args()
     return {'message': 'Music has been updated.', 'data': Controller.update_music(identifier, args)}, 201
示例#11
0
def ui_edit_naming_rule(identifier):
    # Get rule info
    naming_rule = Controller.get_naming_rule(identifier)
    form = NamingRuleForm(formdata=request.form, replace=naming_rule['replace'], replace_by=naming_rule['replace_by'],
                          priority=naming_rule['priority'])

    if naming_rule:
        if request.method == 'POST' and form.validate():
            # save edits
            class Args:
                replace = form.replace.data
                replace_by = form.replace_by.data
                priority = form.priority.data

            Controller.update_naming_rule(identifier, Args())
            return redirect('/ui/naming-rules')
        return render_template('naming_rules/edit_naming_rule.html', form=form, id=naming_rule['id'])
示例#12
0
    def post():
        parser = reqparse.RequestParser()
        parser.add_argument('url', required=True)
        parser.add_argument('name', required=True)
        # Parse the arguments into an object
        args = parser.parse_args()

        return {'message': 'Playlist has been added', 'data': Controller.new_playlist(args)}, 201
示例#13
0
    def post(identifier):
        parser = reqparse.RequestParser()
        parser.add_argument('url', required=True)
        parser.add_argument('name', required=True)
        # Parse the arguments into an object
        args = parser.parse_args()

        return {'message': 'Playlist has been updated.', 'data': Controller.update_playlist(identifier, args)}, 201
示例#14
0
 def post(identifier):
     parser = reqparse.RequestParser()
     parser.add_argument('separator', required=True)
     parser.add_argument('artist_before_title', required=True)
     args = parser.parse_args()
     return {
         'message': 'Channel has been updated.',
         'data': Controller.update_channel(identifier, args)
     }, 201
示例#15
0
 def post(identifier):
     parser = reqparse.RequestParser()
     parser.add_argument('replace', required=True)
     parser.add_argument('replace_by', required=True)
     parser.add_argument('priority', required=True)
     args = parser.parse_args()
     return {
         'message': 'Naming rule has been updated.',
         'data': Controller.update_naming_rule(identifier, args)
     }, 201
示例#16
0
 def post():
     parser = reqparse.RequestParser()
     parser.add_argument('channel', required=True)
     parser.add_argument('separator', required=True)
     parser.add_argument('artist_before_title', required=True)
     args = parser.parse_args()
     return {
         'message': 'Channel has been added.',
         'data': Controller.new_channel(args)
     }, 201
示例#17
0
def ui_edit_playlist(identifier):
    # Get playlist info
    playlist = Controller.get_playlist(identifier)
    form = PlaylistForm(formdata=request.form,
                        name=playlist['name'], youtube_id=playlist['youtube_id'])

    if playlist:
        if request.method == 'POST' and form.validate():
            # save edits
            class Args:
                url = form.url.data
                name = form.name.data

            Controller.update_playlist(identifier, Args())
            return redirect('/ui/playlists')
        return render_template('playlists/edit_playlist.html', form=form,
                               id=playlist['id'],
                               name=playlist['name'],
                               youtube_id=playlist['youtube_id'],
                               uploader=playlist['uploader'])
示例#18
0
def ui_edit_music(identifier):
    # Get music info
    music = Controller.get_music(identifier)
    form = MusicForm(formdata=request.form, title=music['title'], artist=music['artist'],
                     new=music['new'])

    if music:
        if request.method == 'POST' and form.validate():
            # save edits
            class Args:
                title = form.title.data
                artist = form.artist.data
                new = form.new.data

            Controller.update_music(identifier, Args())
            return redirect('/ui/music/new')
        return render_template('music/edit_music.html', form=form,
                               id=music['id'],
                               name=music['name'],
                               title=music['title'],
                               artist=music['artist'],
                               channel=music['channel'],
                               new=music['new'])
示例#19
0
def ui_channels():
    # Declare the table
    class ItemTable(Table):
        channel = Col('channel')
        separator = Col('separator')
        artist_before_title = Col('artist_before_title')
        # Add edit button
        edit = LinkCol('Edit', 'ui_edit_channel', url_kwargs=dict(identifier='channel'))
        # Add delete button
        delete = LinkCol('Delete', 'ui_delete_channel', url_kwargs=dict(identifier='channel'))

    # Get some data
    data = Controller.get_channels()
    # Populate the table
    table = ItemTable(data)
    # Render html
    return render_template("channels/channels.html", table=table)
示例#20
0
def ui_new_music():
    # Declare the table
    class ItemTable(Table):
        id = Col('id')
        name = Col('name')
        title = Col('title')
        artist = Col('artist')
        channel = Col('channel')
        new = Col('new')
        # Add edit button
        edit = LinkCol('Edit', 'ui_edit_music', url_kwargs=dict(identifier='id'))

    # Get some data
    data = Controller.get_new_music()
    # Populate the table
    table = ItemTable(data)
    # Render html
    return render_template("music/new_music.html", table=table)
示例#21
0
def ui_naming_rules():
    # Declare the table
    class ItemTable(Table):
        id = Col('id')
        replace = Col('replace')
        replace_by = Col('replace_by')
        priority = Col('priority')
        # Add edit button
        edit = LinkCol('Edit', 'ui_edit_naming_rule', url_kwargs=dict(identifier='id'))
        # Add delete button
        delete = LinkCol('Delete', 'ui_delete_naming_rule', url_kwargs=dict(identifier='id'))

    # Get some data
    data = Controller.get_naming_rules()
    # Populate the table
    table = ItemTable(data)
    # Render html
    return render_template("naming_rules/naming_rules.html", table=table)
示例#22
0
def ui_playlists():
    # Declare the table
    class ItemTable(Table):
        id = Col('id')
        name = Col('name')
        uploader = Col('uploader')
        # Add edit button
        edit = LinkCol('Edit', 'ui_edit_playlist', url_kwargs=dict(identifier='id'))
        # Add delete button
        delete = LinkCol('Delete', 'ui_delete_playlist', url_kwargs=dict(identifier='id'))
        # Add download button
        download = LinkCol('Download', 'ui_download_playlist', url_kwargs=dict(identifier='id'))

    # Get some data
    data = Controller.get_playlists()
    # Populate the table
    table = ItemTable(data)
    # Render html
    return render_template("playlists/playlists.html", table=table)
示例#23
0
 def get():
     return {'message': 'Success', 'data': Controller.get_channels()}, 200
示例#24
0
 def delete(identifier):
     return {
         'message': 'Channel has been removed.',
         'data': Controller.delete_channel(identifier)
     }, 200
示例#25
0
 def get(identifier):
     return {
         'message': 'Success',
         'data': Controller.get_channel(identifier)
     }, 200
示例#26
0
 def get():
     return {'message': 'Success', 'data': Controller.get_playlists()}, 200
示例#27
0
 def post(playlist_id):
     return {'message': 'Success', 'data': Controller.download_playlist(playlist_id)}, 201
示例#28
0
 def delete(identifier):
     return {'message': 'Playlist has been removed.', 'data': Controller.delete_playlist(identifier)}, 200
示例#29
0
 def get(identifier):
     return {'message': 'Success', 'data': Controller.get_playlist(identifier)}, 200
示例#30
0
 def get():
     return {'message': 'Success', 'data': Controller.convert_mopidy_playlists_to_power_amp()}, 200