public static function autodiscover_feed_url($url){
            $rss =  new moodle_simplepie();
            $rss->set_feed_url($url);
            $rss->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL);
            // When autodiscovering an RSS feed, simplepie will try lots of
            // rss links on a page, so set the timeout high
            $rss->set_timeout(20);
            $rss->init();

            if($rss->error()){
                return $url;
            }

            // return URL without quoting..
            $discoveredurl = new moodle_url($rss->subscribe_url());
            return $discoveredurl->out(false);
    }