00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00032
00033 #ifdef HAVE_CONFIG_H
00034 #include "autoconfig.h"
00035 #endif
00036
00037 #ifdef ONLINE_SERVICES
00038
00039 #include "zmm/zmm.h"
00040 #include "zmmf/zmmf.h"
00041 #include "mxml/mxml.h"
00042 #include "online_service.h"
00043 #include "online_service_helper.h"
00044 #include "config_manager.h"
00045
00046 #ifdef YOUTUBE
00047 #include "youtube_video_url.h"
00048 #include "youtube_content_handler.h"
00049 #include "cached_url.h"
00050 #include "content_manager.h"
00051 #endif
00052
00053 using namespace zmm;
00054
00055 OnlineServiceHelper::OnlineServiceHelper()
00056 {
00057 }
00058
00059 String OnlineServiceHelper::resolveURL(Ref<CdsItemExternalURL> item)
00060 {
00061 if (!item->getFlag(OBJECT_FLAG_ONLINE_SERVICE))
00062 throw _Exception(_("The given item does not belong to an online service"));
00063
00064 service_type_t service = (service_type_t)(item->getAuxData(_(ONLINE_SERVICE_AUX_ID)).toInt());
00065 if (service > OS_Max)
00066 throw _Exception(_("Invalid service id!"));
00067
00068 String url;
00069
00070 switch (service)
00071 {
00072 #ifdef YOUTUBE
00073 case OS_YouTube:
00074 {
00075 url = ContentManager::getInstance()->getCachedURL(item->getID());
00076 if (string_ok(url))
00077 break;
00078
00079 Ref<YouTubeVideoURL> yt_url;
00080 yt_url = Ref<YouTubeVideoURL> (new YouTubeVideoURL());
00081
00082
00083 url = yt_url->getVideoURL(item->getServiceID().substring(1),
00084 ConfigManager::getInstance()->getBoolOption(CFG_ONLINE_CONTENT_YOUTUBE_FORMAT_MP4), ConfigManager::getInstance()->getBoolOption(CFG_ONLINE_CONTENT_YOUTUBE_PREFER_HD));
00085 Ref<CachedURL> cached(new CachedURL(item->getID(), url));
00086 ContentManager::getInstance()->cacheURL(cached);
00087 }
00088 break;
00089 #endif
00090 #ifdef SOPCAST
00091 case OS_SopCast:
00092 url = item->getLocation();
00093 break;
00094 #endif
00095 #ifdef WEBORAMA
00096 case OS_Weborama:
00097 url = item->getLocation();
00098 break;
00099 #endif
00100 #ifdef ATRAILERS
00101 case OS_ATrailers:
00102 url = item->getLocation();
00103 break;
00104 #endif
00105 case OS_Max:
00106 default:
00107 throw _Exception(_("No handler for this service!"));
00108 }
00109
00110 return url;
00111 }
00112
00113 #endif//ONLINE_SERVICES