e constructor. This may be more useful where you want to use other serialization
systems (e.g. JSON, XML, etc) to store configuration, which can be manipulated into a HashRef to
be passed into th
ed_documents {
'application/javascript' => 'Padre::Plugin::JavaScript::Document',
'application/json' => 'Padre::Plugin::JavaScript::Document',
;
}
sub plugin_name {
Wx::gettext('JavaScript');
hash_data EXTENSIONS get_user_config_dir get_win_codepage
is_program_on_path get_terminal_width json_unescape
convert_sami_subtitles_to_srt from_xml);
sub debug(@) {
# Remove some sensitive dat
per JSON parser, but want to avoid the dependency for now..
# (There is now one in FlashVideo::JSON, so consider that -- this is just here
# until we have a chance to fix things using it).
sub json_un
ite::Youtube;
use strict;
use Encode;
use HTML::Entities;
use FlashVideo::Utils;
use FlashVideo::JSON;
use URI::Escape;
my @formats = (
{ id => 38, resolution => [4096, 2304] },
{ id => 37, reso
p method from page ($1)";
return $self->download_fmt_map($prefs, $browser, $title, {}, @{from_json $1});
}
my $video_id;
if ($browser->content =~ /(?:var pageVideoId =|(?:CFG_)?VIDEO_ID'?\s
\s*(\{.*?\});/ && (my $swf = from_json($1))) {
$swf_url = $swf->{url};
} elsif($browser->content =~ /src=\\['"]([^'"]+\.swf)/) {
$swf_url = json_unescape($1);
} else {
//www.wat.tv/interface/contentv2/$video_id");
my $title = json_unescape(($browser->content =~ /title":"(.*?)",/)[0]);
my $url = json_unescape(($browser->content =~ /files.*?url":"(.*?)",/)[0]);
ion => '1.6.0.3');
my($content) = $browser->content =~ /content":\s*"(.*?)"\s*}/;
$content = json_unescape($content);
debug "Content is '$content'";
$browser->update_html($content);
}
sub tr
$browser, $embed_url) = @_;
my $metadata = { };
my ($video_id, $player_id);
# URL params, JSON, etc..
$video_id = ($browser->content =~ /(?:clip|video)Id["'\] ]*[:=]["' ]*(\d+)/i)[0];
$pl
ghtweight OAuth api for SinaWeibo
use strict;
use warnings;
use base 'Net::SinaWeibo::OAuth';
use JSON;
use constant {
SINA_SITE => 'http://api.t.sina.com.cn/',
SINA_REQUEST_TOKE
CCESS_TOKEN_URL => 'http://api.t.sina.com.cn/oauth/access_token',
SINA_FORMAT => 'json',
};
# SINA SDK API
our %SINA_API = (
public_timeline => {
uri => 'statuses/public_ti
i_error_code
Get last api error_code, which return by provider. If provider reponse is
not valid JSON message, it's just the http status code.
=head2 last_api_error_subcode
Get detail error code ab
} else {
die "Unable to find download link";
}
# TODO - support subtitles. Available in JSON (urgh):
# http://www.ted.com/talks/subtitles/id/453/lang/eng
# The ID can be pulled out of
use OAuth::Lite::AuthMethod qw(:all);
use List::MoreUtils qw(any);
use HTTP::Request::Common;
use JSON;
use OAuth::Lite::Util qw(normalize_params);
use constant {
SINA_SITE => 'http
authorize',
SINA_ACCESS_TOKEN_PATH => '/oauth/access_token',
SINA_FORMAT => 'json',
};
__PACKAGE__->mk_accessors(qw(
last_api
last_api_error
last_api_error_code
la
croak $content;
}
decode_json($content);
}
sub _api_error {
my ($self,$error,$http_code) = @_;
eval {
my $error = decode_json($error);
$self->last_api_error($e
ponse is a JSON data structure
return parse_video_info( $browser, $browser->content );
}
# The JSON video info hash has everything we need
sub parse_video_info {
my ( $browser, $json ) = @_;
debug "Video data: $json";
=begin
JSON structure:
{
"data": [
{
"tt": "0",
"ct": "f",
"cs": "2128",
"logo": "http:\/\/vimg8.yoqoo.com\/1100641F464A093EE7A01B01
( $json =~ /"seed":(\d+)/ );
die "Can't find the seed value in the video info JSON"
unless $shuffle_seed;
# Sometimes, the video has a HQ version in mp4 format
my ( $streams ) = ( $json =~
e Carp qw/croak/;
use Date::Format;
use DateTime::Format::Natural;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH
XMLout $obj, RootName=>'vehicleinformation', GroupTags => { stops => 'stop' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
transformed into other data formats
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
=head1 METHODS
I::Liveboard::VERSION = '0.003';
}
use strict;
use Carp qw/croak/;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH'
'liveboard', GroupTags => { departures => 'departure', arrivals => 'arrival' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
transformed into other data formats
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
<liveboard s
e Carp qw/croak/;
use Date::Format;
use DateTime::Format::Natural;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH
turn XMLout $obj, RootName=>'stations', GroupTags => { stations => 'station' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
he data unnested for easier access.
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
<stations>
package WebService::Etsy;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Carp;
use WebService::Etsy::Response;
use IO::File;
use WebService::Etsy::Resource;
use base qw( Clas
s the Etsy API, as described at L<http://developer.etsy.com/>.
The API is RESTful, and returns JSON. This module abstracts this away to present a standard Perl object interface.
The API methods
. $resp->status_line );
return;
}
$self->log( $log_msg );
my $data = from_json( $resp->content );
my $detail = ( $data->{ params } && ref $data->{ params } eq "HASH" ) ?
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;
my $ua = LWP::UserAgent->new;
my $api_key = shift @ARGV;
if ( ! defined $api_key ) {
print STDERR "No API key supplied\n
or getting method table: " . $resp->status_line . "\n";
exit 0;
}
my $method_response = from_json $resp->content;
$Data::Dumper::Terse = 1;
$Data::Dumper::Indent = 0;
print qq(
package WebServi
#!/usr/bin/perl
use Data::Dumper;
use JSON::XS;
use LWP::UserAgent;
###############################################################################
## Station Data Dumper - copyright (c) 2010 Tim Ess
# requote ident & non nums
my $json_string = $js; # js is munged to JSON now
# decode the json_strong
my $station_list = decode_json($json_string);
# map to a handy str
e Carp qw/croak/;
use Date::Format;
use DateTime::Format::Natural;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH
ns',KeepRoot => 0, GroupTags => { connections => 'connection', vias => 'via' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
transformed into other data formats
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
=head1 METHODS
ostende', date => 'tomorrow afternoon'
# JSON station lookup of all stations matching qr/oost/
print irail station => qr/oost/, dataType => 'json'
# XML vehicle lookup
print irail ve
ould override some internals.
my $irail = new WWW::IRail::API( client => 'LWP', dataType => 'JSON' );
=head2 lookup_stations(I<key => 'value'> | I<{key => 'value'}>)
Method which takes a string
} );
my $json_string = $irail->lookup_stations(filter => qr/./, dataType => 'JSON');
=head1 FEATURES
=head2 Multiple output formats
The returned results can be in either XML, JSON or YAML form
ostende', date => 'tomorrow afternoon'
# JSON station lookup of all stations matching qr/oost/
print irail station => qr/oost/, dataType => 'json'
# XML vehicle lookup
print irail ve
ta.
=head1 FEATURES
=head2 Multiple output formats
The returned results can be in either XML, JSON or YAML format. You can even
select between two flavours XML (xml, XML) to suit your taste. Ofcou