Friday, September 13, 2013

Downloading and trimming clips

There are two ways to download the clips, and get them the converted for Mythtv (the right times, etc)

1) twitchtv:
# youtube-dl "http://www.twitch.tv/riotgamesoceania/b/457578762"
downloads many parts
# for i in *.flv; do echo "file '$i'"; done > inputs.txt
# ffmpeg -f concat -i inputs.txt -c copy output.mp4

Youtube doesn't need this, because they show up as one file. However, they do still need to be trimmed. If you need to trim it then, mark the times.

For example:
'input.webm' start: 5:27:00 end: 8:28:28
Then you can convert the file with ffmpeg:
# ffmpeg -y -ss 5:27:00 -t 3:01:28 -i 'input.webm' -c copy 'output.webm'

Monday, September 2, 2013

Django logging

Django has a pretty configurable logging facility.

The other day I had to customize error emails in django.

I did this by copying django's AdminEmailHandler, to a local file, and then pointing the logging utility to this.

The django guide has a large configuration that you can strip. Let's strip it down to this:

LOGGING = {
    'version': 1,
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': False,
        },
    },
}
 
Note the default configuration for the class. This is also where you copied the AdminEmailHandler. Point it to the new location that you saved it. I wasn't sure of a good place so I saved it in 'project/middleware/custom_email.py' and referenced it: "project.middleware.custom_email.AdminEmailHandler"

Now all you need to do is change the email handler to return emails the way you want. I stripped out the file so that it was just the classs and the required dependancies, because I didn't want to override other things that I didn't need to.