-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pulls all data and saves config settings Review and Improved
- Loading branch information
1 parent
a945d14
commit 3b79153
Showing
5 changed files
with
1,154 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,49 @@ | ||
listing_id: 41501 | ||
timezone: -5 | ||
dst: true | ||
firstRun: false | ||
lu: '36648' | ||
tz: America/Toronto | ||
startTime: 0 | ||
endTime: 0 | ||
channelNumber: true | ||
subChannelNumber: true | ||
callsign: false | ||
listingId: false | ||
listDateTime: false | ||
duration: false | ||
showId: false | ||
seriesId: false | ||
showName: false | ||
episodeTitle: false | ||
episodeNumber: false | ||
parts: false | ||
partNumber: false | ||
seriesPremiere: false | ||
seasonPremiere: false | ||
seriesFinale: false | ||
seasonFinale: false | ||
repeat: false | ||
newShow: false | ||
rating: false | ||
captioned: false | ||
educational: false | ||
blackwhite: false | ||
subtitled: false | ||
live: false | ||
hd: false | ||
descriptiveVideo: false | ||
inProgress: false | ||
showTypeId: false | ||
breakoutLevel: false | ||
showType: false | ||
year: false | ||
guest: false | ||
cast: false | ||
director: false | ||
starRating: false | ||
description: false | ||
league: false | ||
team1: false | ||
team2: false | ||
sportEvent: false | ||
location: false | ||
showPicture: false | ||
showTitle: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
namespace Tvscraper; | ||
|
||
use Symfony\Component\Yaml\Yaml; | ||
use Symfony\Component\Yaml\Exception\ParseException; | ||
|
||
/** | ||
* tvscraper - tvpassport tv schedule scraper | ||
* | ||
* @author module17 | ||
* @author Fenrisulfir | ||
* | ||
* @package tvscraper | ||
* | ||
* @version 2.01 | ||
* | ||
*/ | ||
|
||
class Config { | ||
/** | ||
* MEMBER FIELDS | ||
* @var array|mixed $config Description | ||
* | ||
* METHODS | ||
* @method | ||
* @method mixed getSetting(string $setting) | ||
* @method array getSettings() | ||
* @method void saveSetting(string $setting, mixed $value) | ||
* @method void saveSettings(mixed[] $config) | ||
*/ | ||
|
||
private $config = [ | ||
"firstRun" => "1", | ||
"lu" => "", | ||
"tz" => "", | ||
"startTime" => "", | ||
"endTime" => "", | ||
"channelNumber" => "", | ||
"subChannelNumber" => "", | ||
"callsign" => "", | ||
"listingId" => "", | ||
"listDateTime" => "", | ||
"duration" => "", | ||
"showId" => "", | ||
"seriesId" => "", | ||
"showName" => "", | ||
"episodeTitle" => "", | ||
"episodeNumber" => "", | ||
"parts" => "", | ||
"partNumber" => "", | ||
"seriesPremiere" => "", | ||
"seasonPremiere" => "", | ||
"seriesFinale" => "", | ||
"seasonFinale" => "", | ||
"repeat" => "", | ||
"newShow" => "", | ||
"rating" => "", | ||
"captioned" => "", | ||
"educational" => "", | ||
"blackwhite" => "", | ||
"subtitled" => "", | ||
"live" => "", | ||
"hd" => "", | ||
"descriptiveVideo" => "", | ||
"inProgress" => "", | ||
"showTypeId" => "", | ||
"breakoutLevel" => "", | ||
"showType" => "", | ||
"year" => "", | ||
"guest" => "", | ||
"cast" => "", | ||
"director" => "", | ||
"starRating" => "", | ||
"description" => "", | ||
"league" => "", | ||
"team1" => "", | ||
"team2" => "", | ||
"sportEvent" => "", | ||
"location" => "", | ||
"showPicture" => "", | ||
"showTitle" => "" | ||
]; | ||
|
||
public function __construct() { | ||
try { | ||
$this->config = Yaml::parse(file_get_contents(__DIR__ . '/../config.yml')); | ||
|
||
} catch (ParseException $e) { | ||
throw new \Exception(sprintf('Unable to parse the YAML config file: %s', $e->getMessage())); | ||
} | ||
|
||
|
||
$this->saveSettings($this->config); | ||
|
||
} | ||
|
||
public function saveSetting($setting, $value) { | ||
foreach ($this->config as $k => $v) { | ||
if ($k == $setting) { | ||
$this->config[$setting] = $value; | ||
} | ||
} | ||
file_put_contents(__DIR__ . '/../config.yml', Yaml::dump($this->config)); | ||
} | ||
|
||
public function saveSettings($config) { | ||
foreach ((array) $config as $k => $v) { | ||
$this->config[$k] = $v; | ||
} | ||
file_put_contents(__DIR__ . '/../config.yml', Yaml::dump($this->config)); | ||
} | ||
|
||
public function getSetting($setting) { | ||
return $this->config[$setting]; | ||
} | ||
|
||
public function getSettings() { | ||
return $this->config; | ||
} | ||
} |
Oops, something went wrong.