MythTV  0.28pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Functions | Variables
yrnoxml.pl File Reference

Go to the source code of this file.

Functions

use POSIX qw (strftime)
 
 our ($opt_v, $opt_t, $opt_T, $opt_l, $opt_u, $opt_d, $opt_D)
 
 binmode (STDOUT,":utf8")
 
 if (!-d $logdir)
 
 getopts ('Tvtlu:d:D')
 
 if (defined $opt_v)
 
 if (!(defined $opt_u &&defined $loc &&!$loc eq""))
 
 log_print ($logdir,"-u $units -d $dir $loc\n")
 
foreach $node ($nodeset->get_nodelist)
 
foreach my $hashref (@forecast)
 
for my $attr (sort keys%attrib)
 
foreach my $attr ($node->getAttributes)
 
foreach my $subnode ($node->getChildNodes)
 
 if ((-e $cachefile) and((stat($cachefile))[9] >=($now-$timeout)))
 
$ua timeout (30)
 
$ua default_header ('Accept-Language'=>"en")
 
 if (!$response->is_success)
 
$ua default_header ('Accept'=> $accept)
 
return decode_json ($content)
 
 if ($units ne"SI")
 
return strftime a blocaltime ($time)
 

Variables

use strict
 
use warnings
 
use utf8
 
use JSON
 
my $name = 'yrno-XML'
 
my $version = 0.4
 
my $author = 'Gavin Hurlbut'
 
my $email = 'gjhurlbu@gmail.com'
 
my $updateTimeout = 15*60
 
my $retrieveTimeout = 30
 
my types
 
my $dir = "/tmp/yrnoxml"
 
my $logdir = "/tmp/yrnoxml"
 
my images
 
my $loc = shift
 
my attrib
 
my $units = $opt_u
 
my $base_url
 
 $file
 
 $attrib {"station_id"} = $loc
 
my $nodeset = $xp->find('/weatherdata/location/location')
 
my $node
 
my $tzoffset
 
$tzoffset *my $now = time
 
my $lastperiod = undef
 
my forecast
 
my $day = 0
 
my $time = 0
 
 exit
 
sub nodeToHash
 
my $nodename = $node->getName
 
sub getCachedXML
 
my $cachefile = "$dir/$file"
 
my $xp = XML::XPath->new(filename => $cachefile)
 
 else
 
my $ua = LWP::UserAgent->new
 
$ua env_proxy
 
my $response = $ua->get($url)
 
open OF
 Addition for GDAL : START. More...
 
print OF $response content
 
sub getCachedJSON
 
my $accept = "application/json, text/javascript, */*; q=0.01"
 
open IF
 
sub convert_temp
 
my $deg
 
sub parse_date
 
sub format_date
 
return strftime a b e
 
return strftime a bH
 
sub convert_alt
 
my $alt
 
sub log_print
 
open $dir yrnoxml log
 
print OF _
 

Function Documentation

use POSIX qw ( strftime  )
our (   $opt_v,
  $opt_t,
  $opt_T,
  $opt_l,
  $opt_u,
  $opt_d,
  $opt_D 
)
binmode ( STDOUT  ,
":utf8"   
)
if ( !-d  $logdir)

Definition at line 54 of file yrnoxml.pl.

getopts ( 'Tvtlu:d:D'  )
if ( defined  $opt_v)

Definition at line 60 of file yrnoxml.pl.

if ( defined $opt_u &&defined $loc &&!$loc eq"")

Definition at line 111 of file yrnoxml.pl.

log_print (   $logdir,
"-u $units -d $dir $loc\n  
)
foreach $node (   $nodeset->)

Definition at line 141 of file yrnoxml.pl.

foreach my $hashref ( forecast)

Definition at line 179 of file yrnoxml.pl.

Referenced by $attr(), and $subnode().

for my $attr ( sort keys attrib)

Definition at line 214 of file yrnoxml.pl.

Referenced by $attr().

foreach my $attr (   $node->)

Definition at line 227 of file yrnoxml.pl.

foreach my $subnode (   $node->)

Definition at line 231 of file yrnoxml.pl.

if ( (-e $cachefile) and((stat($cachefile))[9] >=($now-$timeout))  )

Definition at line 244 of file yrnoxml.pl.

$ua timeout ( 30  )
$ua default_header ( 'Accept-Language'  ,
"en"   
)
if ( !$response->  is_success)

Definition at line 255 of file yrnoxml.pl.

$ua default_header ( 'Accept'  ,
  $accept 
)
return decode_json (   $content)
if (   $units ne"SI")

Definition at line 310 of file yrnoxml.pl.

return strftime a b Y localtime (   $time)

Referenced by localtime_r().

Variable Documentation

use strict

Definition at line 4 of file yrnoxml.pl.

use warnings

Definition at line 5 of file yrnoxml.pl.

use encoding utf8
use JSON

Definition at line 14 of file yrnoxml.pl.

$name = 'yrno-XML'

Definition at line 21 of file yrnoxml.pl.

my $version = 0.4

Definition at line 22 of file yrnoxml.pl.

my $author = 'Gavin Hurlbut'

Definition at line 23 of file yrnoxml.pl.

my $email = 'gjhurlbu@gmail.com'

Definition at line 24 of file yrnoxml.pl.

my $updateTimeout = 15*60

Definition at line 25 of file yrnoxml.pl.

my $retrieveTimeout = 30

Definition at line 26 of file yrnoxml.pl.

my types
Initial value:
= ( '3dlocation',
'6dlocation', 'altitude', 'cclocation', 'copyright', 'date-0',
'date-1', 'date-2', 'date-3', 'date-4', 'date-5', 'geobaseid',
'high-0', 'high-1', 'high-2', 'high-3', 'high-4', 'high-5',
'low-0', 'low-1', 'low-2', 'low-3', 'low-4', 'low-5',
'icon-0', 'icon-1', 'icon-2', 'icon-3', 'icon-4', 'icon-5',
'latitude', 'longitude', 'observation_time',
'18hrlocation',
'18icon-0', '18icon-1', '18icon-2',
'18icon-3', '18icon-4', '18icon-5',
'temp-0', 'temp-1', 'temp-2', 'temp-3', 'temp-4', 'temp-5',
'time-0', 'time-1', 'time-2', 'time-3', 'time-4', 'time-5',
'pop-0', 'pop-1', 'pop-2', 'pop-3', 'pop-4', 'pop-5',
'updatetime', 'station_id', 'copyrightlogo' )

Definition at line 27 of file yrnoxml.pl.

my $dir = "/tmp/yrnoxml"

Definition at line 41 of file yrnoxml.pl.

my $logdir = "/tmp/yrnoxml"

Definition at line 42 of file yrnoxml.pl.

Referenced by if().

my images
Initial value:
= ( "partly cloudy" => "pcloudy.png", "cloudy" => "cloudy.png",
"sleet" => "rainsnow.png", "fair" => "fair.png",
"snow" => "flurries.png", "rain" => "showers.png",
"sunny" => "sunny.png", "fog" => "fog.png",
"mostly cloudy" => "mcloudy.png",
"rain showers" => "lshowers.png", "heavy rain" => "showers.png",
"thunder showers" => "thunshowers.png",
"unknown" => "unknown.png" )

Definition at line 43 of file yrnoxml.pl.

Referenced by MainServer::HandleMusicFindAlbumArt(), ImageLoader::LoadAnimatedImage(), SubtitleScreen::RenderAssTrack(), and MythUIImage::SetAnimationFrames().

my $loc = shift

Definition at line 110 of file yrnoxml.pl.

my attrib

Definition at line 115 of file yrnoxml.pl.

Referenced by VAAPIContext::InitContext(), and VAAPIContext::SetPictureAttribute().

my $units = $opt_u

Definition at line 116 of file yrnoxml.pl.

my $base_url
Initial value:
= 'http:
my $file = $loc

Definition at line 120 of file yrnoxml.pl.

$file
Initial value:
=~ s/\
my $xp = getCachedXML($base_url . $loc . "/forecast.xml", $dir, $file . ".xml",

Definition at line 122 of file yrnoxml.pl.

$attrib {"station_id"} = $loc

Definition at line 127 of file yrnoxml.pl.

Referenced by $attr(), and $node().

$nodeset = $xp->find('/weatherdata/location/location')

Definition at line 129 of file yrnoxml.pl.

foreach $node

Definition at line 130 of file yrnoxml.pl.

my $tzoffset

Definition at line 154 of file yrnoxml.pl.

my $now = time

Definition at line 160 of file yrnoxml.pl.

my $lastperiod = undef

Definition at line 166 of file yrnoxml.pl.

my forecast

Definition at line 167 of file yrnoxml.pl.

my $day = 0

Definition at line 177 of file yrnoxml.pl.

return $time = 0

Definition at line 178 of file yrnoxml.pl.

Referenced by $time().

exit

Definition at line 217 of file yrnoxml.pl.

sub nodeToHash
Initial value:
{

Definition at line 222 of file yrnoxml.pl.

Referenced by $subnode().

my $nodename = $node->getName

Definition at line 225 of file yrnoxml.pl.

sub getCachedXML
Initial value:
{
my ($url, $dir, $file, $timeout, $logdir) = @_

Definition at line 236 of file yrnoxml.pl.

open $cachefile or die Can t open $cachefile = "$dir/$file"

Definition at line 239 of file yrnoxml.pl.

my $xp = XML::XPath->new(filename => $cachefile)

Definition at line 240 of file yrnoxml.pl.

else
Initial value:
{
log_print( $logdir, "$url\ncaching to $cachefile\n" )

Definition at line 247 of file yrnoxml.pl.

my $ua = LWP::UserAgent->new

Definition at line 249 of file yrnoxml.pl.

$ua env_proxy

Definition at line 251 of file yrnoxml.pl.

my $response = $ua->get($url)

Definition at line 254 of file yrnoxml.pl.

close OF

Addition for GDAL : START.

Addition for GDAL : END.

Definition at line 259 of file yrnoxml.pl.

print OF $response content
sub getCachedJSON
Initial value:
{
my ($url, $dir, $file, $timeout, $logdir) = @_

Definition at line 269 of file yrnoxml.pl.

my $accept = "application/json, text/javascript, */*; q=0.01"

Definition at line 282 of file yrnoxml.pl.

open<:utf8",$cachefileordie"Can'topen$cachefile:$!\n";my$content=do{local$/;<IF> close IF

Definition at line 299 of file yrnoxml.pl.

sub convert_temp
Initial value:
{
my ( $degC, $units ) = @_

Definition at line 306 of file yrnoxml.pl.

return $deg

Definition at line 308 of file yrnoxml.pl.

sub parse_date
Initial value:
{
my ( $date, $tzoffset ) = @_

Definition at line 318 of file yrnoxml.pl.

Referenced by $hashref().

sub format_date
Initial value:
{
my ($time) = @_

Definition at line 326 of file yrnoxml.pl.

return strftime a b e

Definition at line 329 of file yrnoxml.pl.

Referenced by UPnpDeviceDesc::_InternalLoad(), MultiValueImp::add(), AAFilter::calculateCoeffs(), PBHEventHandler::CheckAvailability(), PlaybackBoxHelper::CheckAvailability(), AudioOutputJACK::CloseDevice(), copy_entries(), NetworkControl::customEvent(), TV::customEvent(), PlaybackBox::Delete(), PlaybackBoxHelper::DeleteRecordings(), DecoderBase::DoFastForwardSeek(), XMLParseBase::doLoad(), doLoadScreens(), DecoderBase::DoRewindSeek(), MythTimer::elapsed(), enhance(), cCiMMI::Enquiry(), TV::event(), MythTerminalKeyFilter::eventFilter(), MythMainWindow::eventFilter(), UnzipPrivate::extractFile(), MultiValueImp::fill_from_db(), filter_line_c(), NativeArchive::findNodeText(), ImageUtils::GetAllExifValues(), Parse::GetEnclosures(), ImageUtils::GetExifValue(), getFileDetails(), NuppelDecoder::GetFrame(), MythUIStateTracker::GetFreshState(), PlaybackBoxHelper::GetPreviewImage(), PreviewGeneratorQueue::GetPreviewImage(), hamm24(), NativeArchive::importRecording(), NativeArchive::importVideo(), AudioOutputJACK::JackCallback(), MythLocale::LoadDefaultsFromXML(), loadDetailsFromXML(), MythBurn::loadEncoderProfiles(), MythUIVirtualKeyboard::loadKeyDefinitions(), loadScreen(), PlaybackBoxHelper::LocateArtwork(), MediaMonitor::mediaStatusChanged(), MythMainWindow::mouseTimeout(), MThreadPool::NotifyAvailable(), NuppelDecoder::OpenFile(), AudioOutputBase::OutputAudioLoop(), parse_dom(), UPNPScanner::ParseDevice(), XMLTVParser::parseFile(), Parse::ParseItem(), MythUIVirtualKeyboard::parseKey(), PlayListFile::parseM3U(), MythThemedMenu::parseMenu(), PlayListFile::parsePLS(), NewsSite::parseRSS(), UPNPScanner::ParseService(), UPNPScanner::ParseServiceList(), ThemeInfo::parseThemeInfo(), DeviceReadBuffer::Poll(), DecoderBase::PosMapFromDb(), DecoderBase::PosMapFromEnc(), post_event(), HttpStatus::PrintBackends(), HttpStatus::PrintEncoderStatus(), HttpStatus::PrintFrontends(), HttpStatus::PrintJobQueue(), HttpStatus::PrintMachineInfo(), HttpStatus::PrintMiscellaneousInfo(), HttpStatus::PrintScheduled(), MythUDPListener::Process(), UPnpDeviceDesc::ProcessDeviceList(), UPnpDeviceDesc::ProcessIconList(), MenuBase::ProcessIncludes(), UPNPSubscription::ProcessRequest(), UPnpDeviceDesc::ProcessServiceList(), HTTPRequest::ProcessSOAPPayload(), avfDecoder::run(), CdDecoder::run(), LogServerThread::run(), LoggerThread::run(), PreviewGeneratorQueue::SendEvent(), SOAPClient::SendSOAPRequest(), set_decode_parms(), ImageUtils::SetExifValue(), SetMarkup(), FileLogger::setupZMQSocket(), SyslogLogger::setupZMQSocket(), DatabaseLogger::setupZMQSocket(), MenuBase::Show(), NetStream::slotSslErrors(), AudioOutputBase::Status(), PlaybackBoxHelper::StopRecording(), LiveTVChain::SwitchTo(), PlaybackBoxHelper::UndeleteRecording(), PlaybackBoxHelper::UpdateFreeSpace(), and XMLParseBase::WindowExists().

return strftime a b Y H

Definition at line 329 of file yrnoxml.pl.

Referenced by denoise(), denoiseMMX(), and surf3d_draw().

sub convert_alt
Initial value:
{
my ( $altm, $units ) = @_

Definition at line 332 of file yrnoxml.pl.

Referenced by $node().

return $alt

Definition at line 334 of file yrnoxml.pl.

sub log_print
Initial value:
{
return if not defined $opt_D

Definition at line 344 of file yrnoxml.pl.

Referenced by if().

open $dir yrnoxml log
print OF _

Definition at line 349 of file yrnoxml.pl.