⬆️ ⬇️

Burn DVD with Django

Recently installed a server with Azureus Web UI to download movies. But there was one problem - DVD recording for viewing on a home theater. A little search and did not find a web application for recording discs, well, let's write it ourselves.







The main idea of ​​the script is to allow the user to select a directory or file on the server and execute the write command from the dvd + rw-tools package:

growisofs -dvd-compat -Z <device> -R -J -pad "<path to directory for writing>"
to movies laid out without VIDEO_TS need to add it:

growisofs -dvd-compat -Z <device> -R -J -pad -graftpoints "/ VIDEO_TS = <path to the directory for recording>"


')





Django features used:



unused features do not interfere at all, thanks to the modular architecture of Django.







Let's start with the wrapper library over growisofs. It is quite simple, the Burner object in the constructor accepting the name of the recording device, tries to determine the growisofs version and if it does not exist, causes an exception. In the object, the burndvd method with the path parameter, using subprocess.Popen, tries to cut the disk. Errors are determined by reading stderr and are reflected by calling a few exceptions.







The most interesting part of the application is the user interface.



The rule of forming url:

 urlpatterns = patterns ('',
	 (r '^ / dvdburn $', 'default.dvdburn.views.index', {'dirname': ''}),
	 (r '^ / dvdburn / (? P <dirname> [^?] +) / $', 'default.dvdburn.views.index'),
 )


all that starts with / dvdburn falls into the index method, the rest of the url is passed as the dirname parameter.







The view index method contains the main part of the script logic.

In this method, the path to the movie storage root is added to the path received in the url, the path is divided into components for placing links to the parent directories, the contents of the current path are passed to the navigation pattern . If a post call is detected, the recording starts, in the current version the process display is not implemented, so while the recording is in progress, the page will load, and the result template will be displayed at the end of the recording.



What I would like to improve:

Source: https://habr.com/ru/post/28983/



All Articles