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 6559699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:21:46+00:00 2026-05-25T13:21:46+00:00

I used to embed YouTube video’s via a link I have in a database.

  • 0

I used to embed YouTube video’s via a link I have in a database.

YouTube no longer allows me to embed in this fashion. Instead, I need to extract the video ID from the URL I have stored.

Here is an example of the link:

http://www.youtube.com/watch?v=72xSxQIRelc&feature=youtube_gdata

The ID I need to extract is 72xSxQIRelc. I know I could do something like:

string vidID = 
    preURL.Substring(preURL.LastIndexOf("v=") + 2,
    preURL.Substring(preURL.LastIndexOf("v=") + 2).Length -
    preURL.Substring(preURL.LastIndexOf("&feature")).Length)

I’ve seen some Regex stuff on here that does this. I’m wondering if my way is horribly inefficient, comparatively. I’m also not a regex kung fu wizard, so I’m not sure if the solutions I’m seeing are scalable if YouTube changes the URL structure (in this case, it’s hard coded to require v= as well as &feature).

My solution still seems pretty hackish to me. Is there a more efficient way of doing this?


Added

This app is wrapped in a silverlight solution, so I should mention that here.

One posted solution was to use HttpUtility.ParseQueryString. That looked like it was the answer, up until I discovered that Silverlight’s implementation of HttpUtility doesn’t include the ParseQueryString method.

  • 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-05-25T13:21:47+00:00Added an answer on May 25, 2026 at 1:21 pm

    then you should just update your database no?

    UPDATE 
        [VideosTable]
    SET
        video_url = 
            SUBSTRING(
                video_url, 
                CHARINDEX('v=', video_url) + 2,
                CHARINDEX('&', video_url, CHARINDEX('v=', video_url)) -
                (CHARINDEX('v=', video_url) + 2)
            )
    WHERE
        video_url LIKE '%youtube.com%'; 
    

    Then you can simply use the video ID that comes from the Database…

    if you are uploading the video ID from the hole link, use the URI object instead

    Uri youtube = new Uri("http://www.youtube.com/watch?v=72xSxQIRelc&feature=youtube_gdata");
    string videoId = HttpUtility.ParseQueryString(youtube.Query)["v"];
    

    Silverlight update

    Silveright lack two things, the support for the ParseQueryString part of the System.Web.HttpUtility and the System.Collections.Specialized.NameValueCollection

    So, why not just add that functionality yourself?

    Because HttpUtility is already a static object you can’t extend this, but you can easily create yourself something new:

    public static class MyHttpUtilities
    {
        public static System.Collections.Generic.Dictionary<string, string>
            ParseQueryString(this string queryString)
        {
            System.Collections.Generic.Dictionary<string, string> r = 
                new Dictionary<string, string>();
            // remove extra noise
            queryString = queryString.TrimStart('?').Replace("amp;", ""); 
            // split up and fill up Dictionary
            foreach (string s in queryString.Split('&'))
            {
                if (s.Contains('='))
                {
                    string[] par = s.Split('=');
                    r.Add(par[0], par[1]);
                }
            }
            return r;
        }
    }
    

    and then use:

    string videoId = MyHttpUtilities.ParseQueryString(youtube.Query)["v"],
           feature = MyHttpUtilities.ParseQueryString(youtube.Query)["feature"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the HTML5 embed code from this page: http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html <iframe class=youtube-player type=text/html
I have used a iframe video in my web page. This is my html
I have this piece of HTML: <div class=embed> <iframe width=300 height=200 frameborder=0 allowfullscreen= src=http://www.youtube.com/embed/123456></iframe>
I've embedded a video from YouTube via a snippet I've found on the Internet,
I want to play you tube video using uiwebview and I have used following
I'm using the jQuery Youtube plugin to embed a youtube video and use some
i have used embed tag for Flv file, Flash Player for swf file and
I used standard Youtube embed code like: <div style=width:100%; max-width:800px;> <iframe width=960 height=720 src=http://www.youtube.com/embed/VIDEO_ID
Have a series of YouTube videos that I want to embed without having to
Ok so basically I used the following Youtube Chanel embed code: <script src=http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/youtube.xml&amp;up_channel=tomdesigner777&amp;synd=open&amp;w=320&amp;h=390&amp;title=&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js></script> And

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.