/ Published in: Perl
Dumps your snippets (and possibly skips your favourites [British spelling]) to standard output. Requires Frontier::RPC2.
Expand |
Embed | Plain Text
#!/usr/bin/perl -w use strict; use Frontier::Client; my $key = ''; # (your API key) my $user = ''; # used to skip others' snippets (fill with your user name) my $session = Frontier::Client->new( url => 'http://snipplr.com/xml-rpc.php', debug => 0,); $session->call('user.checkkey', $key) my @args = ($key, ''); my $list = $session->call('snippet.list', @args); my @snippets; # in case you need to process data afterwards (sort ...) my $data = $session->call('snippet.get', $_->{'id'}); if ($data->{username} !~ /^$user$/) {next}; # skip favorites (back up just your snippets) $snippets[$i]=$data; # dump for post loop processing print "##### $data->{title}\n"; print "##### $data->{comment}\n"; print "##### $data->{language} $data->{tags}\n"; print "##### $data->{source}\n"; print "#####\n"; print "#####\n"; }
Comments
Subscribe to comments
You need to login to post a comment.

You can also download a zip file backup of your snippets here: http://snipplr.com/zipbackup.php
@tylerhall Thank you very much, I didn't notice the "download a ZIP file backup of all your snippets" link in the Settings tab. I fact, I was just going to improve my script to get exactly that: a dump in separate files. Still, the script can be useful to selectively back up scripts.