File: NzbHandler_Save.php

package info (click to toggle)
spotweb 20130826%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,132 kB
  • ctags: 11,281
  • sloc: php: 31,367; xml: 1,009; sh: 148; makefile: 83
file content (34 lines) | stat: -rwxr-xr-x 893 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
class NzbHandler_Save extends NzbHandler_abs
{
	private $_localDir = null;
	
	function __construct(SpotSettings $settings, array $nzbHandling)
	{
		parent::__construct($settings, 'Save', 'Save', $nzbHandling);
		
		$this->_localDir = $nzbHandling['local_dir'];
		if (empty($this->_localDir))
		{
			throw new InvalidLocalDirException("Unable to save NZB file, local dir in config is empty");
		} # if
		
	} # __construct
	
	
	public function processNzb($fullspot, $nzblist)
	{
		$nzb = $this->prepareNzb($fullspot, $nzblist);
		
		$path = $this->makeNzbLocalPath($fullspot, $this->_localDir);
		$filename = $path . $nzb['filename'];
		
		# Sla de NZB file op het lokale filesysteem op
		if (file_put_contents($filename, $nzb['nzb']) === false)
		{
			throw new InvalidLocalDirException("Unable to write NZB file to: " . $filename);
		} # if
		
	} # processNzb

} # class NzbHandler_Save