Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (34 sloc) 1.821 kb
a7b5f9c9 »
2012-01-24 Fixing invoke, fixing ordering.
1 <?php
2
3 $playlist_sync = array();
4
5 // YOU CAN EDIT THIS SECTION
6 $playlist_sync[] = array('rdio_playlist_id' => 526420, 'itunes_url' => 'http://itunes.apple.com/us/rss/topsongs/limit=100/explicit=true/json'); // top songs us
7 $playlist_sync[] = array('rdio_playlist_id' => 526666, 'itunes_url' => 'http://itunes.apple.com/us/rss/topsongs/limit=100/genre=18/explicit=true/json'); // top hip-hop/rap us
8 $playlist_sync[] = array('rdio_playlist_id' => 526674, 'itunes_url' => 'http://itunes.apple.com/us/rss/topsongs/limit=100/genre=14/explicit=true/json'); // pop
9 $playlist_sync[] = array('rdio_playlist_id' => 526679, 'itunes_url' => 'http://itunes.apple.com/us/rss/topsongs/limit=100/genre=20/explicit=true/json'); // alternative
10 $playlist_sync[] = array('rdio_playlist_id' => 526683, 'itunes_url' => 'http://itunes.apple.com/us/rss/topsongs/limit=100/genre=21/explicit=true/json'); // rock
11
12 // DO NOT EDIT PAST HERE
13 require_once 'config.php';
14 require_once 'rdio/php/rdio.php';
15
16 $rdio = new Rdio(array(RDIO_KEY, RDIO_SECRET));
17
18 if (file_exists('.session.json'))
19 {
20 $session = json_decode(file_get_contents('.session.json'), true);
21 $rdio->token = array($session['token'], $session['secret']);
22 }
23
24 if (empty($session))
25 {
26 $url = $rdio->begin_authentication('oob');
27 print "Please go to the following URL.\n";
28 print "$url\n\n";
29 print "Please enter the code it provides: ";
30 $verifier = trim(fgets(STDIN));
31 $rdio->complete_authentication($verifier);
32
33 $session['token'] = $rdio->token[0];
34 $session['secret'] = $rdio->token[1];
35
36 $file = fopen('.session.json', 'w');
37 fwrite($file, json_encode($session));
38 fclose($file);
39 }
40
41 foreach ($playlist_sync as $playlist)
42 exec('php ' . dirname(__FILE__) . '/itunes-to-rdio.php ' . $playlist['rdio_playlist_id'] . ' ' . $playlist['itunes_url'] . ' &');
43
44 ?>
Something went wrong with that request. Please try again.