Skip to content

Commit

Permalink
Updated for new site compatability
Browse files Browse the repository at this point in the history
Pulls all data and saves config settings

Review and Improved
  • Loading branch information
Fenrisulfir committed Aug 16, 2016
1 parent a945d14 commit 3b79153
Show file tree
Hide file tree
Showing 5 changed files with 1,154 additions and 225 deletions.
52 changes: 49 additions & 3 deletions config.yml
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
120 changes: 120 additions & 0 deletions src/Config.php
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;
}
}
Loading

0 comments on commit 3b79153

Please sign in to comment.