MrGibbage
MrGibbage

Reputation: 2646

Dealing with C# namespaces

I am working on a project that will need to ability to download youtube videos. I found this project on github:

https://github.com/flagbug/YoutubeExtractor

My project already has a namespace. How would I import the YoutubeExtractor into my project? Do I need to change the namespace for it before (or after) importing it? Or is it up to me, in which case, what are the advantages and disadvantages to changing the namespace vs. not changing it? I am using VS Express 2012, if that matters.

Upvotes: 0

Views: 210

Answers (2)

Mike Perrenoud
Mike Perrenoud

Reputation: 67898

  1. Open the project that exists for the YouTubeExtractor and build it.
  2. Move the outputted assembly to a location inside your project structure.
  3. Add a reference to that assembly.
  4. Add a using {namespace} to the files you want to use the extractor in.

Where {namespace} is the namespace it uses.

Further, it appears that there is a nuget package for it (you see that YoutubeExtractor.nuspec file in root). I would recommend installing nuget into Visual Studio and then searching nuget for the YouTubeExtractor. It's a lot easier, and you get updates with it easier as well.

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

My project already has a namespace. How would I import the YoutubeExtractor into my project?

You add reference to the external assembly (in this particular case you install the NuGet) and then add using statement with the correct namespace (YoutubeExtractor) in which the classes are defined.

So just follow the steps described on the home page:

Install-Package YoutubeExtractor

and then:

using YoutubeExtractor;

and finally:

// Our test youtube link
string link = "insert youtube link";

/*
* Get the available video formats.
* We'll work with them in the video and audio download examples.
*/
IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);

Upvotes: 5

Related Questions