Skip to content

Commit

Permalink
Add test for post porcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
d0u9 committed Apr 11, 2018
1 parent 3d47bcc commit c7879bc
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
40 changes: 40 additions & 0 deletions youtube_dl_webui/test/post_processor/post_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from os import chdir
import youtube_dl


class MyLogger(object):
def debug(self, msg):
pass

def warning(self, msg):
pass

def error(self, msg):
print(msg)


def my_hook(d):
if d['status'] == 'finished':
print('Done downloading, now converting ...')

if __name__ == '__main__':
chdir('/tmp')

ydl_opts = {
# 'format': 'bestaudio+best',
'format': 'bestvideo+bestaudio',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'logger': MyLogger(),
'progress_hooks': [my_hook],
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
40 changes: 40 additions & 0 deletions youtube_dl_webui/test/postprocessor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from os import chdir
import youtube_dl


class MyLogger(object):
def debug(self, msg):
pass

def warning(self, msg):
pass

def error(self, msg):
print(msg)


def my_hook(d):
if d['status'] == 'finished':
print('Done downloading, now converting ...')

if __name__ == '__main__':
chdir('/tmp')

ydl_opts = {
# 'format': 'bestaudio+best',
'format': 'bestvideo+bestaudio',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'logger': MyLogger(),
'progress_hooks': [my_hook],
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])

0 comments on commit c7879bc

Please sign in to comment.