Commit e317d872 authored by jan.koester's avatar jan.koester
Browse files

test

parent 4be2f9f9
Loading
Loading
Loading
Loading
+8 −6
Changes for plugins/youtube/youtube.cpp: 8 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ namespace blogi {
            if(!syncId.empty()){
                try{
                    libhtmlpp::HtmlString syncOut;
                    SyncYoutube(tid, atoi(syncId.c_str()), syncOut);
                    SyncYoutube(tid, syncId, syncOut);
                    syncMessage = tr(_lang,"Sync completed!");
                }catch(libhttppp::HTTPException &e){
                    syncMessage = e.what();
@@ -321,7 +321,7 @@ namespace blogi {
            return jroot;
        }

        void SyncYoutube(const int tid,int channel_id,libhtmlpp::HtmlString &out){
        void SyncYoutube(const int tid,const std::string &channel_id,libhtmlpp::HtmlString &out){
            std::string _lang = getLang(*Args->database[tid]);
            std::vector<char> json;
            libhttppp::HttpResponse res;
@@ -332,8 +332,10 @@ namespace blogi {
            dbpp::DBResult   dbres;

            int rlen=0;
            std::vector<char> idbuf;
            const std::string chid = sql.escaped(idbuf, channel_id.c_str());

            sql << "select channelname,apikey,channelkey from youtube_channels where id='" << channel_id <<"'";
            sql << "select channelname,apikey,channelkey from youtube_channels where id='" << chid <<"'";

            int count = Args->database[tid]->exec(sql,dbres);

@@ -388,7 +390,7 @@ namespace blogi {
                int fcount = json_object_array_length(ytems);

                sql.clear();
                sql << "delete from youtube_videos where youtube_channels_pkey='" << channel_id <<"'";
                sql << "delete from youtube_videos where youtube_channels_pkey='" << chid <<"'";
                Args->database[tid]->exec(sql,dbres);

                for(int i =0; i<fcount; ++i) {
@@ -400,7 +402,7 @@ namespace blogi {
                                uuid::uuid vidId;
                                vidId.generate();
                                sql.clear();
                                sql << "INSERT INTO youtube_videos (id,youtube_channels_pkey,youtube_id) VALUES ('" << vidId.c_str() << "','" << channel_id << "','" << json_object_get_string(yid) << "')";
                                sql << "INSERT INTO youtube_videos (id,youtube_channels_pkey,youtube_id) VALUES ('" << vidId.c_str() << "','" << chid << "','" << json_object_get_string(yid) << "')";
                                Args->database[tid]->exec(sql,dbres);
                            }
                        }
@@ -430,7 +432,7 @@ namespace blogi {
                if(Args->auth->isLoggedIn(tid,req,sessionid)){
                    try{
                        size_t surl=Args->config->buildurl("youtube/sync/").length();
                        SyncYoutube(tid,atoi( req.getRequestURL().substr(surl,req.getRequestURL().length()-surl).c_str()),out);
                        SyncYoutube(tid,req.getRequestURL().substr(surl),out);
                        youdiv.appendChild(out.parse());
                    }catch(libhttppp::HTTPException &e){
                        std::string error;