示例#1
0
    std::string Resource::extractID(const pugi::xml_node& node, const std::string& file, const std::string& def)
    {
        std::string id = node.attribute("id").value();
        if (id.empty())
        {
            if (file.empty())
                return lower(def);
            return extractID(file);
        }

        return lower(id);
    }
示例#2
0
void Parser3::ParseUrl( QUrl U )
{
    if( !U.isValid() )
        return;
    BasePtr Info;

    Parser3_Sender *S=0;


    QString Url;

    QString ID = extractID( U );
    UrlType Type = getUrlType( U );

    switch( Type ) {
    case( UT_Video ):
    case( UT_Video_Feed ):
        Url = "http://gdata.youtube.com/feeds/api/videos/"+ID+"?v=2";
        Info = new VideoInfo;
        S = new Parser3_Sender(this, Info );
        connect( S, SIGNAL(Signal(BasePtr,QDomDocument)), SLOT(VideoRecived(BasePtr,QDomDocument)) );
        break;
    case( UT_Playlist ):
    case( UT_Playlist_Feed ):
        Url = "http://gdata.youtube.com/feeds/api/playlists/"+ID+"?v=2&start-index=1&max-results=50";
        Info = new VideoFeed;
        Info->cast_VideoFeed()->Type = VideoFeed::FT_Playlist;
        S = new Parser3_Sender( this, Info );
        connect( S, SIGNAL(Signal(BasePtr,QDomDocument)), SLOT(PlaylistRecived(BasePtr,QDomDocument)) );
        break;
    case( UT_User ):
    case( UT_User_Feed ):
        Url = "http://gdata.youtube.com/feeds/api/users/"+ID+"?v=2";
        Info = new UserInfo;
        S = new Parser3_Sender( this, Info );
        connect( S, SIGNAL(Signal(BasePtr,QDomDocument)), SLOT(UserRecived(BasePtr,QDomDocument)) );
        break;
    default:
        Error( QString("Unown url type! Url[%1]").arg(Url) );
    }

    mQue.push_back( qMakePair( QNetworkRequest(QUrl(Url)),QPointer<Parser3_Sender>(S)) );

}