3
MediaTomb - http://www.mediatomb.cc/
5
youtube_service.h - this file is part of MediaTomb.
7
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
10
Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
11
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
Leonhard Wimmer <leo@mediatomb.cc>
14
MediaTomb is free software; you can redistribute it and/or modify
15
it under the terms of the GNU General Public License version 2
16
as published by the Free Software Foundation.
18
MediaTomb is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
23
You should have received a copy of the GNU General Public License
24
version 2 along with MediaTomb; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
27
$Id: youtube_service.h 1698 2008-02-23 20:48:30Z lww $
30
/// \file youtube_service.h
31
/// \brief Definition of the YouTubeService class.
33
#if defined(YOUTUBE) // make sure to add more ifdefs when we get more services
35
#ifndef __YOUTUBE_SERVICE_H__
36
#define __YOUTUBE_SERVICE_H__
39
#include "mxml/mxml.h"
40
#include "online_service.h"
42
#include "dictionary.h"
53
YT_list_by_category_and_tag
59
YT_cat_film_and_animation = 1,
60
YT_cat_autos_and_vehicles = 2,
62
YT_cat_pets_and_animals = 15,
64
YT_cat_travel_and_places = 19,
65
YT_cat_gadgets_and_games = 20,
66
YT_cat_people_and_blogs = 22,
68
YT_cat_entertainment = 24,
69
YT_cat_news_and_politics = 25,
70
YT_cat_howto_and_diy = 26
73
/// \brief This is an interface for all online services, the function
74
/// handles adding/refreshing content in the database.
75
class YouTubeService : public OnlineService
80
/// \brief Retrieves user specified content from the service and adds
81
/// the items to the database.
82
virtual bool refreshServiceData(zmm::Ref<Layout> layout);
84
/// \brief Get the type of the service (i.e. YouTube, Shoutcast, etc.)
85
virtual service_type_t getServiceType();
87
/// \brief Get the human readable name for the service
88
virtual zmm::String getServiceName();
90
/// \brief Parse the xml fragment from the configuration and gather
91
/// the user settings in a service task structure.
92
virtual zmm::Ref<zmm::Object> defineServiceTask(zmm::Ref<mxml::Element> xmlopt);
94
/// \brief Get the human readable name of a particular request type, i.e.
95
/// did we request Favorites or Featured videos, etc.
96
static zmm::String getRequestName(yt_methods_t method);
98
/// \brief Get the human readable category name
99
static zmm::String getCategoryName(yt_categories_t category);
102
// the handle *must never be used from multiple threads*
104
// safeguard to ensure the above
107
// url retriever class
110
/// \brief This function will retrieve the XML according to the parametrs
111
zmm::Ref<mxml::Element> getData(zmm::Ref<Dictionary> params);
113
/// \brief This class defines the so called "YouTube task", the task
114
/// holds various parameters that are needed to perform. A task means
115
/// the process of downloading, parsing service data and creating
117
class YouTubeTask : public zmm::Object
122
/// \brief Method identifier
125
/// \brief Category identifier, only used with the
126
/// YT_list_by_category_and_tag method
127
yt_categories_t category;
129
/// \brief parameter=value for the REST API URL
130
zmm::Ref<Dictionary> parameters;
132
/// \brief Amount of items that we are allowed to get.
135
/// \brief Amount of items that have been fetched.
138
/// \brief Current page for requests that require paging
141
/// \brief Playlist name defined by the user (only set if method
142
/// equals YT_list_by_playlist)
143
zmm::String playlist_name;
146
/// \brief task that we will be working with when refreshServiceData is
150
/// \brief utility function, returns true if method supports paging
151
bool hasPaging(yt_methods_t method);
153
// helper functions for parsing config.xml
154
zmm::String getCheckAttr(zmm::Ref<mxml::Element> xml, zmm::String attrname);
155
int getCheckPosIntAttr(zmm::Ref<mxml::Element> xml, zmm::String attrname);
156
void addPagingParams(zmm::Ref<mxml::Element> xml,
157
zmm::Ref<YouTubeTask> task);
160
#endif//__ONLINE_SERVICE_H__