Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:48:32+00:00 2026-06-18T09:48:32+00:00

I am trying to get total duration of a youtube playlist using youtube data

  • 0

I am trying to get total duration of a youtube playlist using youtube data api. I download response from, for example, http://gdata.youtube.com/feeds/api/playlists/63F0C78739B09958 and my idea is to iterate over each <yt:duration='xxx'/> occurences where xxx is each video duration in seconds, and sum them up to get total playlist runtime.

For getting each i use CAtlRegExp with the following string:

<yt:duration seconds='{[0-9]+}'/>

however it matches only the first occurence, not any of the rest (referring to the source code pasted below, the loop iterates only once).

I tried some other regex strings like

  • (<yt:duration seconds='{[0-9]+}'/>)

  • (<yt:duration seconds='{[0-9]+}'/>)*

however they didn’t work either (the same reason).

Here is an extract from source code, where the for loop only iterates once because mcDuration.m_uNumGroups equals to 1:

    //get video duration
    CAtlRegExp<> reDurationFinder;
    CAtlREMatchContext<> mcDuration; 

    REParseError status = reDurationFinder.Parse(_T("<yt:duration seconds='{[0-9]+}'/>"));

    if ( status != REPARSE_ERROR_OK )
    {
        // Unexpected error.
        return false;
    }

    if ( !reDurationFinder.Match(sFeed, &mcDuration) ) //i checked it with debug, sFeed contains full response from youtube data api
    {
        //cannot find video url
        return false;
    }

    m_nLengthInSeconds = 0;
    for ( UINT nGroupIndex = 0; nGroupIndex < mcDuration.m_uNumGroups; ++nGroupIndex )
    {
        const CAtlREMatchContext<>::RECHAR* szStart = 0;
        const CAtlREMatchContext<>::RECHAR* szEnd = 0;
        mcDuration.GetMatch(nGroupIndex, &szStart, &szEnd);

        ptrdiff_t nLength = szEnd - szStart;
        m_nLengthInSeconds += _ttoi(CString(szStart, nLength));
    }

How can I make CAtlRegExp match all of the occurences of <yt:duration ... ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:48:33+00:00Added an answer on June 18, 2026 at 9:48 am

    You will always have the first (next) occurrence only. To find others you need to keep Match‘ing in a loop until no more occurrences found.

        for(; ; )
        {
            CAtlREMatchContext<> MatchContext;
            pszNextText = NULL;
            if(!Expression.Match(pszText, &MatchContext, &pszNextText))
                break;
            // Here you process the found occurrence
            pszText = pszNextText;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a total record count from the below Method using
I'm trying to get the total height of a page using JavaScript so I
I am trying to get a total of 25 associations from the database. I
I'm stuck trying to get the total number of pizzas eaten using django My
Trying to get data in the most efficient way possible for some reports, using
I am trying to get the total count of rows from Sqlite DB. Following
I'm trying to code a progress bar...i'm using the youtube api to create custom
Im trying to get the total unread accounts from the database, the value is
Hello I am trying to get the entire total page size with HttpWebRequest from
I'm trying to get specific data from the smartctl command. I want to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.