Skip to content

Commit

Permalink
Merge pull request #560 from koter84/nzb-head-meta-password
Browse files Browse the repository at this point in the history
merge password meta elements from nzb into merged nzb
  • Loading branch information
Sweepr committed Jul 13, 2020
2 parents 7597521 + eeec0ef commit 0d8a9c6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/services/NzbHandler/Services_NzbHandler_abs.php
Expand Up @@ -223,6 +223,32 @@ protected function mergeNzbList($nzbList)
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb"></nzb>');

$domNzbXml = dom_import_simplexml($nzbXml);

$dom = new DOMDocument('1.0', 'utf-8');
$domHead = $dom->createElement('head');
foreach ($nzbList as $nzb) {
$oneNzbFile = simplexml_load_string($nzb['nzb']);

// go through all the head -> meta elements
foreach ($oneNzbFile->head->meta as $meta) {
// check for password type
if ($meta['type'] == 'password') {
// create a meta element with the password as value
$domMeta = $dom->createElement('meta', ''.$meta[0]);
// create attribute: type=password
$domAttribute = $dom->createAttribute('type');
$domAttribute->value = 'password';
// append attribute to meta-element
$domMeta->appendChild($domAttribute);
// append meta-element to head
$domHead->appendChild($domMeta);
}
}
}
// import head into result xml
$domHead = $domNzbXml->ownerDocument->importNode($domHead, true);
$domNzbXml->appendChild($domHead);

foreach ($nzbList as $nzb) {
$oneNzbFile = simplexml_load_string($nzb['nzb']);

Expand Down

0 comments on commit 0d8a9c6

Please sign in to comment.