Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/fixes #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/vendor/
/.idea/
/vendor/
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/encodings.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/misc.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/php.xml

This file was deleted.

115 changes: 0 additions & 115 deletions .idea/podcastFeed.iml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/scopes/scope_settings.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/vcs.xml

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/webResources.xml

This file was deleted.

12 changes: 12 additions & 0 deletions download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env php
<?php
// http://symfony.com/doc/current/components/console/introduction.html

require __DIR__.'/vendor/autoload.php';

use Zippo\Console\Command\DownloadP1SommarVinter;
use Symfony\Component\Console\Application;

$application = new Application();
$application->add(new DownloadP1SommarVinter());
$application->run();
2 changes: 2 additions & 0 deletions downloadP3Popular.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ do
break 2
else
echo "$LENGTH failed."
#sleep random 1-10 sec
sleep $[ ( $RANDOM % 4 ) + 1 ]s
fi
done
done
Expand Down
50 changes: 50 additions & 0 deletions src/Zippo/Console/Command/DownloadP1SommarVinter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Zippo\Console\Command;

use DateTime;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Zippo\podcastFeed\Cache;
use Zippo\podcastFeed\Model;

class DownloadP1SommarVinter extends Command
{
protected function configure()
{
$this
->setName('download:p1sommar')
->setDescription('ladda ner p1sommar')
->addArgument('date', InputArgument::OPTIONAL)
;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$date = $input->getArgument('date');
if ($date) {
$dateTime = new DateTime($date);
} else {
$dateTime = new DateTime('today');
}

$cache = new Cache();
$data = $cache->getP1Cache();
if (count($data) == 0) {
$url = 'http://sverigesradio.se/sida/avsnitt?programid=2071';
#$url = 'http://sverigesradio.se/sida/ajax/getplayerinfo?url=http%3A%2F%2Fsverigesradio.se%2Fsida%2Favsnitt%2F562300%3Fprogramid%3D2071%26playepisode%3D562300';
$str = Model::getStringForUrl($url);
$data = explode("\n", $str);
$cache->writeToCache($data);
} else {
$output->writeln('found cache');
}
//http://lyssnaigen.sr.se/isidor/ereg/webb_rh_sthlm/2015/06/47_sommar_i_p1_med_david_bat_34b3756_a192.m4a
$pattern = "/^47_sommar_i_p1(.*)\.a96$/";
$nameList = preg_grep($pattern, $data);

$output->writeln(var_export($data));
}
}
34 changes: 31 additions & 3 deletions src/Zippo/podcastFeed/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Zippo\podcastFeed;

use SimpleXMLElement;

class Model
{

Expand Down Expand Up @@ -155,23 +157,49 @@ private function getShowFromFileMeta(FileMeta $fileMeta)
}

/**
* @return \SimpleXMLElement
* @return SimpleXMLElement
*/
private static function getXmlForSommar()
{
/*
* old url (redirect to below?)
// http://api.sr.se/api/rssfeed/rssfeed.aspx?lyssnaigenfeed=2071
// broadcast. original byut short desc
// http://sverigesradio.se/api/rss/broadcast/2071
*/
// pod sommar more desc
$url = 'http://api.sr.se/api/rss/pod/4023';
return self::getXmlForUrl($url);
}

/**
* @param string $url
* @return SimpleXMLElement
*/
public static function getXmlForUrl($url)
{
$str = self::getStringForUrl($url);
$xml = new SimpleXMLElement($str);
return $xml;
}

/**
* @param string $url
* @return string
*/
public static function getStringForUrl($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$str = curl_exec($curl);
curl_close($curl);
$xml = new \SimpleXMLElement($str);
return $xml;
return $str;
}


public static function getInfoP1Sommar()
{
$cache = new Cache();
Expand Down
Binary file added testdata/.DS_Store
Binary file not shown.