YouTube Data Analysis Using Hadoop1
YouTube Data Analysis Using Hadoop1
A Project
ACHARYA NAGARJUNA UNIVERSITY
2021-2022
DECLARATION
Degree
G.NAGALAKSHMI Y193175252
DECLARATION
Degree
Degree
I.SREEVANI Y193175255
DECLARATION
Degree
M.KOMALI Y193175279
DECLARATION
Degree
CERTIFICATE 2021-2022
This is to certify that this
project work entitled
ABSTRACT
of
Analysis of structured data has seen tremendous success in the past. However,
analysis of large scale unstructured data in the form of video format remains a
challenging area. YouTube, a Google company, has over a billion users and generates
billions of views. Since YouTube data is getting created in a very huge amount and with
an equally great speed, there is a huge demand to store, process and carefully study this
how data generated from YouTube can be mined and utilized to make targeted, real time
that allows the applications/websites to incorporate functions that are used by YouTube
application to fetch and view information. The Google Developers Console is used to
generate a unique access key which is further required to fetch YouTube public channel
data. Once the API key is generated, a .Net(C#) based console application is designed to
use the YouTube API for fetching video(s) information based on a search criteria. The
text file output generated from the console application is then loaded from HDFS v
(Hadoop Distributed File System) file into HIVE database. Hive uses a SQL-like
interface to query data stored in various databases and file systems that integrate with
Hadoop. HDFS (Hadoop Distributed File System) is a primary Hadoop application and a
user can directly interact with HDFS using various shell-like commands supported by
Hadoop. This project uses SQL like queries that are later run on Big Data using HIVE to
extract the meaningful output which can be used by the management for analysis.
vi
ACKNOWLEDGEMENTS
I would first like to thank B.S.R.K PRASAD GARU for allowing me to work on
such an interesting and fun project. He was instrumental to my success in this project. He
was very supportive and understanding provided me an extra push and confidence to
succeed in this venture. He took an extra effort to review the report and provide his
invaluable feedback.
my Bachelor Degree and guiding me all the way to become a successful student.
Last but not the least, I am thankful to my family for their constant support and
belief in me, their words of wisdom and moral support helped me to overcome all the
challenges. With their guidance, I was able to successfully complete my project and earn
my Bachelor Degree.
vii
TABLE OF CONTENTS
Page
Acknowledgements.................................................................................................................................vii
INTRODUCTION.....................................................................................................................................1
BACKGROUND........................................................................................................................................5
viii
YOUTUBE DATA ANALYSIS USING HADOOP ........................................................ 21
6.2 Creating a .Net(C#) Console Application to Use the YouTube API ................. 38
CONCLUSION ................................................................................................................. 50
Appendix ........................................................................................................................... 52
Bibliography ..................................................................................................................... 57
ix
List of Figures
Figures
Page
Figure 1 High Level Flow Diagram.....................................................................................................7
x
Figure 20 Fetching The Final Data.....................................................................................................44
Figure 27 Output of Country wise analysis of top 15 videos with number of views..........48
xi
1
Chapter 1
INTRODUCTION
With rapid innovations and surge of internet companies like Google, Yahoo,
Amazon, eBay and a rapidly growing internet savvy population, today's advanced
systems and enterprises are generating data in a very huge volume with great velocity
and in a multi-structured formats including videos, images, sensor data, weblogs etc.
from different sources. This has given birth to a new type of data called Big Data which
is unstructured sometime semi structured and also unpredictable in nature. This data is
mostly generated in real time from social media websites which is increasing
According to Wikipedia, “Big Data is a term for data sets that are so large or
complex that traditional data processing applications are inadequate to deal with them.
Analysis of data sets can find new correlations to spot business trends, prevent diseases,
combat crime and so on." [1] With millions of people using Twitter to tweet about their
of people talking about a recently released movie on Facebook and millions of views on
YouTube for a recently released movie trailer, we are at a stage wherein we are heading
into a social media data explosion. Companies are already facing challenges getting
useful information from the transactional data from their customers (for e.g. data captured
by the companies when a customer opens a new account or sign up for a credit card or a
service). This type of data is structural in nature and still manageable. However, social
2
media data is primarily unstructured in nature. The very unstructured nature of the data
makes it very hard to analyze and very interesting at the same time.
Whereas RDBMS is designed to handle structured data and that to only certain
limit, RDBMS fails to handle this kind of unstructured and huge amount of data called
Big Data. This inability of RDBMS has given birth to new database management system
powerful mathematical techniques applied to analyze data and how to process that
data. It is used to extract data and find actionable information which is used to
volume of data for particular users or employees etc. to handle. For that we
need MapReduce function to get the aggregated result as per the query.
storing and retrieving data every minute. The adaptive solution created for the
same was the use of Hadoop including Hadoop Distributed File System or HDFS
3
for performing operations of storing and retrieving data. Hadoop framework has
5. Hive: Hive is a data warehouse system for Hadoop that facilitates ad hoc queries
6. HQL: Hive uses a SQL like language called Hive. HQL is a popular choice
YouTube is one of the most popular and engaging social media tool and an
amazing platform that reveals the community feedback through comments for published
YouTube collects a wide variety of traditional data points including View Counts, Likes,
Votes, and Comments. The analysis of the above listed data points constitutes a very
interesting data source to mine for obtaining implicit knowledge about users, videos,
Most of the companies are uploading their product launch on YouTube and they
anxiously await their subscribers' reviews. Major production houses launch movie
trailers and people provide their first reaction and reviews about the trailers. This further
creates a buzz and excitement about the product. Hence the above listed data points
become very critical for the companies so that they can do the analysis and understand
1. This project will help people in understanding how to fetch a specific channel’s
2. This project requires access to Google Developers Console and generate a unique
access key. That unique key is required to fetch YouTube public channel data.
With the help of the unique access key, the required data is fetched from
3. The extracted data is first stored in HDFS file and then the data is loaded into HIVE
database. The queries are run into HIVE database so that the YouTube data can be
mined intelligently and the findings can be shared with the management.
5
Chapter 2
BACKGROUND
"YouTube has over a billion users and every day people watch hundreds of
millions of hours on YouTube and generate billions of views”[2] . "Every day, people
across the world are uploading 1.2 million videos to YouTube, or over 100 hours per
minute and this number is ever increasing [3]. To analyze and understand the activity
occurring on such a massive scale, a relational SQL database is not enough. Such kind of
data is well suited to a massively parallel and distributed system like Hadoop.
The main objective of this project is to focus on how data generated from
YouTube can be mined and utilized by different companies to make targeted, real time
and informed decisions about their product that can increase their market share. This can
be done by using Hadoop concepts. The given project will focus on how data generated
from YouTube can be mined and utilized. There are multiple applications of this project.
Companies can use this project to understand how effective and penetrative their
marketing programs are. In addition to the view counts, subscribers and shares, audience
retention count, companies can also evaluate views according to date range. This can tell
the companies when is the slow period or spike in viewership and attribute the same to
certain marketing campaign. Applications for YouTube data can be endless. For example,
Companies can analyze how much a product is liked by people. This project can also help
in analyzing new emerging trends and knowing about people's changing behavior with
time. Also people in different countries have different preferences. By analyzing the
6
understand what are the likes/dislikes of people around the world and work on their
preferences accordingly.
This project uses following concepts and tools throughout its lifecycle.
1. Java API
2. Hadoop
3. Hive
4. Unix
6. Data Mining
7. Business Intelligence
7
In this project we fetch a specific channel’s YouTube data using YouTube API.
We will use Google Developers Console and generate a unique access key which is
required to fetch YouTube public channel data. Once the API key is generated, a
.Net(C#) based console application is designed to use the YouTube API for fetching
video(s) information based on a search criteria. The text file output generated from
the console application is then loaded from HDFS file into HIVE database. HDFS is a
primary Hadoop application and a user can directly interact with HDFS using various
shell-like commands supported by Hadoop. Then we run queries on Big Data using
HIVE to extract the meaningful output which can be used by the management for
analysis.
HIVE
Processing data using Database
HIVE query language
Output Results
12
Chapter 3
Wikipedia defines Big Data as "a collection of data sets so large and complex that
it becomes difficult to process using the available database management tools. The
challenges include how to capture, curate, store, search, share, analyze and visualize Big
Data” [1]. In today's environment, we have access to more types of data. These data
sources include online transactions, social networking activities, mobile device services,
Big Data is a collection of data sets that are large and complex in nature. They
constitute both structured and unstructured data that grow large so fast that they are not
Big Data is defined as any kind of data source that has at least three shared
characteristics:
today are at the tipping point in terms of managing data. Data sources are ever expanding.
Data from Facebook, Twitter, YouTube, Google etc., are to grow 50X in the next 10
years. Over 2.5 exabytes of data is generated every day. Some of the sources of
1. A typical large stock exchange captures more than 1 TB of data every day.
2. There are over 5 billion mobile phones in the world which are
4. Large social networks such as Twitter and Facebook capture more than 10 TB
of data daily.
5. There are more than 30 million networked sensors in the world which further
handling large quantities of data. Hence, in order to manage the data in the Big Data world,
new emerging approaches are required, including document, graph, columnar, and geospatial
database architectures. Collectively, these are referred to as NoSQL, or not only SQL,
databases. In essence the data architectures need to be mapped to the types of transactions.
Doing so will help to ensure the right data is available when you need it.
As organizations are getting flooded with massive amount of raw data, the challenge
here is that traditional tools are poorly equipped to deal with the scale and complexity of
such kind of data. That's where Hadoop comes in. Hadoop is well suited to
14
meet many Big Data challenges, especially with high volumes of data and data with a
variety of structures.
interconnected computers (known as nodes) that can work together on the same
2. A distributed file system known as the Hadoop Distributed File System, or HDFS. In
Hadoop you can do any kind any kind of aggregation of data whether it is one-
month old data or one-year-old data. Hadoop provides a mechanism called MapReduce
model to do distributed processing of large data which internally takes care of data even
throughout the system. A framework where a piece of work is divided among several
parallel MapReduce task. Each task operated independently on cheap commodity servers.
This enables businesses to generate values from data that was previously considered too
15
traditional enterprise data warehouse system and would buy the biggest data
warehouse they could afford and store the data on a single machine. However, with the
File System), MapReduce, Yarn, Hive and Hbase. Hadoop has two core components.
‘Storage’ part to store the data and ‘Processing’ part to process the data. The storage
As stated above, the Hadoop Distributed File System (HDFS) is the storage
for extremely large scale storage, which can easily be extended by scaling out. It is
important to mention the difference between scale up and scale out. In its initial days,
Google was facing challenges to store and process not only all the pages on the internet
but also its users’ web log data. At that time, Google was using scale up architecture
model where you can increase the system capacity by adding CPU cores, RAM etc to the
existing server. But such kind of model had was not only expensive but also had
model by using cluster of smaller servers which can be further scaled out if they require
16
more power and capacity. Google File System (GFS) was developed based on this
The core concept of HDFS is that it can be made up of dozens, hundreds, or even
thousands of individual computers, where the system's files are stored in directly
attached disk drives. Each of these individual computers is a self-contained server with
its own memory, CPU, disk storage, and installed operating system (typically Linux,
file system because it lives on top of the file systems that are installed on all individual
The above figure [12] shows that a Hadoop cluster is made up of two classes of
servers: slave nodes, where the data is stored and processed and master nodes, which
17
govern the management of the Hadoop cluster. On each of the master nodes and slave
nodes, HDFS runs special services and stores raw data to capture the state of the file
system. In the case of the slave nodes, the raw data consists of the blocks stored on the
node, and with the master nodes, the raw data consists of metadata that maps data
HDFS is a system that allows multiple commodity machines to store data from a
single source. HDFS consists of a NameNode and a DataNode. HDFS operates as master
comprises of only the Meta data information of HDFS that is the blocks of data that are
space utilization?
The DataNode comprises of data processing, all the processing data that is
The actual storage of the files being processed and serving read and write
In the earlier versions of Hadoop there was only one NameNode attached to the
DataNode which was a single point of failure. Hadoop version 2.x provides multiple
NameNode where secondary NameNode can take over in the event of a primary
18
points in the event of a primary NameNode failure. You can start secondary NameNode
Let’s take look at a data warehouse structure example where we have one
machine and with HDFS we can distribute the data into more than one machine. Let’s
say we have 100 GB of file that takes 20 minutes to process on a machine with a given
number of channel and hard drive. If you add four machines of exactly the same
But what happens if one of these four machines fails? HDFS creates a self-healing
architecture by replicating the same data across multiple nodes. So it can process the data
in a high availability environment. For example, if we have three DataNodes and one
NameNode, the data is transferred from the client environment into HDFS DataNode.
The replication factor defines the number of times a data block is replicated in a clustered
environment. Let’s say we have a file that is split into two data blocks across three
DataNodes. If we are processing these files to a three DataNode cluster and we set the
replication factor to three. If one of the nodes fails, the data from the failed nodes is
redistributed among the remaining active nodes and the other nodes will complete the
processing function.
19
on which machine a particular task is going to be executed. The actual processing of the
task or program will be done by Node Manager. In Hadoop 2.2, YARN augments the
MapReduce platform and serves as the Hadoop operating system. Hadoop 2.2 separates
the resource management function from data processing allowing greater flexibility. This
way MapReduce only performs data processing while resource management is isolated
in YARN. Being the primary resource manager in HDFS, YARN enables enterprises to
store data in a single place and interact with it in multiple ways with consistent levels of
service. In Hadoop 1.0 the NameNode used job tracker and the DataNode used task
tracker to manage resources. In Hadoop 2.x, YARN splits up into two major
functionalities of the job tracker - the resource management and job scheduling. The
client reports to the resource manager and the resource manager allocates resources to
jobs using the resource container, Node Manager and app master. The resource container
splits memory, CPU, network bandwidth among other hardware constraints into a single
unit. The Node Manager receives updates from the resource containers which
communicate with the app master. The Node Manager is the framework for containers,
resource monitoring and for reporting data to the resource manager and scheduler.
MapReduce framework. The Hadoop framework divides the data into smaller chunks and
20
stores divides that data into smaller chucks and stores each part of the data on a separate
node within the cluster. For example, if we have 4 terabytes of data, the HDFS divides
this data into 4 parts of 1TB each. By doing this, the time taken to store the data onto the
disk is significantly reduced. The total time to store this entire data onto the disk is equal
to storing 1 part of the data as it will store all the parts of the data simultaneously on
different machines.
In order to provide high availability what Hadoop does is replicate each part of the
data onto other machines that are present within the cluster. The number of copies it will
replicate depends on the replication factor. By default the replication factor is 3, in such a
case there will be 3 copies of each part of the data on three different machines. In order to
reduce the bandwidth and latency time, it will store two copies on the same rack and third
copy on a different rack. For example, in the above example, NODE 1 and NODE 2 are on
rack one and NODE 3 and NODE 4 are on rack two. Then the first two copies of part 1 will
be stored on NODE 1 and third copy will be stored either on NODE 3 or NODE 4. Similar
process is followed in storing remaining parts of the data. The HDFS takes care of the
Chapter 4
YouTube, owned by Google, is a video sharing website, where users can upload,
watch and share videos with others. YouTube provides a forum for people to connect,
inform, and inspire others across the globe and acts as a distribution platform for original
free direct advertisement, YouTube has also become a launch pad for various
products/services wherein large corporations reveal the first look of the product on
YouTube, generate a buzz about their product, assess the market demand based upon
likes and view counts and improve their product based upon customers' feedback. Hence
the data points including View Counts, Likes, Votes, and Comments etc. become very
critical for the companies so that they can do the analysis and understand the customers'
The main objective of this project is to show how companies can analyze
YouTube data using YouTube API to make targeted real time and informed decisions.
This project will help in understanding changing trends among people by analyzing
YouTube data and fetching meaningful results. For example, when companies like
Disney launch their new movie trailers on YouTube, this application can help Disney in
analyzing the reaction of people towards a specific movie trailer. This application can
analyze home many people liked the trailers, in which country the trailer was liked the
most, whether the comments posted on YouTube are generally positive, negative or
neutral etc. This way management can take executive decisions how to spend their
Since YouTube data is getting created in a very huge amount and with an equally
great speed, there is a huge demand to store, process and carefully study this large
While Hadoop provides the ability to collect data on HDFS (Hadoop Distributed
File System), there are many applications available in the market (like MapReduce, Pig
Let us first take a closer look at all three applications and then analyze which
4.1.1 MapReduce
MapReduce is a set of Java classes run on YARN with the purpose of processing
massive amounts of data and reducing this data into output files. HDFS works with
MapReduce to divide the data in parallel fashion on local or parallel machines. Parallel
structure requires that the data is immutable and cannot be updated. It begins with the
input files where the data is initially stored typically residing in HDFS. These input files
are then split up into input format which selects the files, defines the input splits, breaks
the file into tasks and provides a place for record reader objects. The input format
defines the list of tasks that makes up the map phase. The tasks are then assigned to the
nodes in the system based on where the input files chunks are physically resident. The
input split describes the unit of work that comprises a single map task in a MapReduce
program. The record reader loads the data and converts it into key value pairs that can be
read by the Mapper. The Mapper performs the first phase of the MapReduce program.
Given a key and a value the mappers export key and value pairs and send these values to
the reducers. The process of moving mapped outputs to the reducers is known as
shuffling. Partitions are the inputs to reduce tasks, the partitioner determines which key
and value pair will be stored and reduced. The set of intermediate keys are automatically
stored before they are sent to the reduce function. A reducer instance is created for each
reduced task to create an output format. The output format governs the way objects are
written, the output format provided by Hadoop writes the files to HDFS.
24
4.1.2 Hive
Hive provides the ability to store large amounts of data in HDFS. Hive was
designed to appeal to a community comfortable with SQL. Hive uses an SQL like
language known as HIVEQL. Its philosophy is that we don’t need yet another scripting
language. Hive supports maps and reduced transform scripts in the language of the user’s
choice which can be embedded with SQL. Hive is widely used in Facebook, with analyst
Supporting SQL syntax also means that it is possible to integrate with existing
tools like. Hive has an ODBC (Open Database Connectivity JDBC (Java Database
Connectivity) driver that allows and facilitates easy queries. It also adds support for
indexes which allows support for queries common in such environment. Hive is a
framework for performing analytical queries. Currently Hive can be used to query data
stored in HBase which is a key value store like those found in the gods of most
RDBMS’s (Relational database management system) and the Hadoop database project
4.1.3 Pig
Pig comes from the language Pig Latin. Pig Latin is a procedural programming
language and fits very naturally in the pipeline paradigm. When queries become complex
with most of joins and filters then Pig is strongly recommended. Pig Latin allows pipeline
developers to decide where to checkpoint data in the pipeline. That is storing data in
between operations has the advantage of check pointing data in the pipeline. This ensures
25
the whole pipeline does not has to be rerun in the event of a failure. Pig Latin allows
users to store data at any point in the pipeline without disturbing the pipeline execution.
The advantage that Pig Latin provides is that pipelines developers decide where
appropriate checkpoints are in the pipeline rather than being forced to checkpoint
wherever the schematics of SQL impose it. Pig Latin supports splits in the pipeline.
Common features of data pipelines is that they are often graphics and not linear pipelines
since disk’s read and write scan time and intermediate results usually dominate
processing of large datasets reducing the number of times data must be written to and
Pig Latin allows developers to insert their own code almost anywhere in the data
pipeline which is useful for pipeline development. This is accomplished through a user
defined functions UDFS (User Defined Functions). UDFS allows user to specify how
data is loaded, how data is stored and how data is processed. Streaming allows users to
include executables at any point in the data flow. Pipeline also often includes user
defined columns transformation functions and user defined aggregations. Pig Latin
The following table [4] shows features and comparison of leading Hadoop Data
The YouTube sample dataset collected using .NET console application (see
For this project, dataset is relatively smaller. The dataset is around 2000 records for any given
search criteria across multiple countries. However, in real environment, with the extensive information
available on YouTube the data size can be much larger. Given a video ID, the application first extracts
information from the YouTube API, which contains all the meta-data. The application then scrapes the
video's webpage to obtain the remaining information. The following information of YouTube video is
After extracting the sample dataset from YouTube API (Figure 21 represents the
snapshot of extracted dataset), this dataset can be fed into various Hadoop Technologies
write complex business logic in order to successfully execute the join queries. We
would have to think from map and reduce view of what is important and what is
not important and which particular code little piece will go into map and which
one will go into reduce side. Programmatically, this effort will become quite
logic even for simplest tasks. Also, it may be difficult to map the data into schema
format and lot of development effort may go in to deciding how map and reduce
approach defined by the programmers. Pig requires a learning curve since the
syntax is new and different from SQL. Also, Pig requires more maintenance. The
values of variables may not be retained; instead, the query needs to rerun in order
to get the values from a variable. Moreover, Pig is a scripting language that is
more suitable for prototyping and rapidly developing MapReduce based jobs. The
data schema is not enforced explicitly in Pig and hence it becomes difficult to
29
map the data into schema format. Also, the error that Pig produces is not very user
friendly. It just gives exec error even if the problem is related to syntax or type
error. Pig development may require more time than hive but is purely based on
3. Hive provides a familiar programming model. It operates on query data with a SQL-
based language. It is comparatively faster with better interactive response times, even
over huge datasets. As data variety and volume grows, more commodity machines
can be added without reducing the performance. Hence, Hive is scalable and
extensible. Hive is very compatible and works with traditional data integration and
data analytics tool. If we apply Hive to analyze the YouTube data, then we would be
After looking at the pros and cons, Hive becomes the obvious choice for this
Chapter 5
HADOOP SETUP
Step 1 Create a virtual box on your operating system using the link below
http://www.oracle.com/technetwork/serverstorage/virtualbox/downloads/index.html
Step 2 Setup Hadoop on your virtual box using the link below
http://share.edureka.co/pydio/data/public/hadoop
Step 3 Import the file downloaded from “STEP 2” on your virtual machine
NameNode
ResourceManager
DataNode
Jps
NodeManger
(e.g. /home/hadoop).
Step 2 To compile and execute a program in Hadoop use the following command.
This command is used to create a directory to store the compiled java classes.
$ mkdir units
http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-core/1.2.1
The following commands are used for compiling the ProcessUnits.java program
Step 4 Copy your YouTube Input from local machine into HDFS using
Step 5 Now run your jar file in Hadoop environment run command
Chapter 6
The project utilizes the YouTube Data API that allows the
fetch and view information. The aforementioned data can be used in numerous ways.
To retrieve information from YouTube using their Data API our application needs to
be authenticated. Once the application is authorized we can fetch data that can be used
required, Google Developer allows you to create a unique key to connect to YouTube.
Step 2 To create the unique API key for retrieving data, a new project needs to be
Step 3 Go to https://console.developers.Google.com/project
Step 5 A new project needs to be created. Provide a name for the project
Step 6 To create a new API key Google provides the YouTube Data API that is
available under the developer tools.
Library > YouTube APIs > YouTube Data API
35
Step 7 To utilize the YouTube Data API, it needs to be enabled under the logged in
credentials. Click “Enable” under the YouTube Data API v3.
Dashboard > YouTube Data API v3: Enable
Step 8 Once the YouTube data API is enabled, create credentials in order to
utilize the API. To create credentials
Dashboard > Go to Credentials Button
Step 9 Add credentials to the project. YouTube provides three options for
creating an API Key.
API key
client ID
service account
The project utilizes the “client ID” option
Step 10 Create Client ID: To create a JSON file to fetch data, we need to select the
application that will be using the data. YouTube Data API offers the following
options
Web application
Android
Chrome App
iOS
PlayStation 4
Other
The project utilizes the “Other” option
37
Step 12 YouTube creates the Client ID for the project to utilize and provides the
API Key
Step 2 Next step is to add the required DLLs to the .NET project. The Dlls can be
new[] { YouTubeService.Scope.YouTubeReadonly },
"user", System.Threading.CancellationToken.None, new
FileDataStore("YouTubeKey")).Result; }
return service;
}
The Auth function gets the user credentials from “YouTube_Client.json” and uses
Step 5 Create an array to set a list of countries. The list of counties codes from taken
from https://countrycode.org/
Step 7 Using YouTube services loop through the countries to get a list of records
Step 8 Based on the search criteria list item. Loop through each video id to obtain
additional information. The following modules were used to fetch the video
information
o Snippet
o ContentDetails
o Localizations
o Statistics
o Status
43
Step 9 Populate the export file with the information about the
video.
string appDirectory =
AppDomain.CurrentDomain.BaseDirectory.Replace(@"bin\Debug\", "");
File.WriteAllText(appDirectory + "Results.txt", sbuilBuilder.ToString());
This command will create a Hive table named ‘YouTube_data_table’ in which rows will
Use the command given below to load YouTube data into the Hive table created in
64 Output Result
Step 1 Calculate top 10 channels with maximum number of likes
We can extract the top 10 channels with maximum number of likes using the following
Hive query. The Hive select query will trigger the following MapReduce job:
Output Result
The output result describes that for a specific video id, how many likes were received. The
number of likes -- or "thumbs-up" -- a video had has a direct significance to the YouTube
YouTube, then the number of YouTube likes the company has could determine whether the
company or its competitors appear more prominently in YouTube search results. The output
Output Results
According to data gathered in the dataset, the output results show 'Entertainment' and
'Film & Animation' are some of the bigger categories. On the other hand, number of
comments generated were most for the videos tagged under 'Comedy' category. This
output shows if there is a pattern of affinity of interests for certain category and for
falls under 'Entertainment' section, they would be better off launching their new
48
product/service on YouTube. On the other hand, if the company falls under 'Comedy' or
Output Results
Figure 27 Output of Country wise analysis of top 15 videos with number of views
49
The above output displays the Top 15 videos with maximum number of views for a
specific channel in a specific country. This type of analysis can be used for multi-national
companies who have a strong YouTube footprint. YouTube has a very large viewer and
subscriber base all over the world. When companies like Disney launch their movie
trailers, an analysis can be performed to identify which trailer was liked the most in
which country. Based upon that analysis, a global company like Disney can distribute the
Chapter 7
CONCLUSION
7.1 Conclusion
The task of big data analysis is not only important but also a necessity. In fact
many organizations that have implemented Big Data are realizing significant competitive
advantage compared to other organizations with no Big Data efforts. The project is
intended to analyze the YouTube Big Data and come up with significant insights which
The output results of YouTube data analysis project show key insights that can be
extrapolated to other use cases as well. One of the output results describes that for a specific
video id, how many likes were received. The number of likes -- or "thumbs-up" -
- a video had has a direct significance to the YouTube video's ranking, according to
YouTube Analytics. So if a company posts its video on YouTube, then the number of
YouTube likes the company has could determine whether the company or its competitors
for certain video category. This can be done by analyzing the comments count. For e.g., if
the company falls under 'Comedy' or 'Education' category, a meaningful discussion in the
The future work would include extending the analysis of YouTube data
using other Big Data analysis Technologies like Pig and MapReduce and do a
One feature that is not added in the project is to represent the output in a Graphical
User Interface (GUI). The current project displays a very simplistic output which does not
warrant a GUI interface. However, if the output is too large and complex, the output can be
interfaced in a GUI format to display the results. The data can then be presented in different
Analysis project. The current scope of the project includes analyzing the statistics for a
channel/category including view counts, likes, dislikes, country wise view etc. By
opinion minding can be performed for a specific video. This would tell us writer's attitude
specific subject/video.
52
APPENDIX
Source Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using System.IO;
using System.Net.Mime;
using System.Text;
using System.Xml;
namespace YouTubeTagExtraction
{
public class YouTubeInterfaceClass
{
private static readonly YouTubeService YtService = Auth();
UserCredential creds;
//appDirectory gets the path of the "YouTube_Client.json" file that has the UserCredential.
string appDirectory = AppDomain.CurrentDomain.BaseDirectory.Replace(@"bin\Debug\", "");
using (var stream = new FileStream(appDirectory + "YouTube_Client.json", FileMode.Open,
FileAccess.Read))
{
creds = GoogleWebAuthorizationBroker.AuthorizeAsync(
53
GoogleClientSecrets.Load(stream).Secrets,
new[] { YouTubeService.Scope.YouTubeReadonly },
"user", System.Threading.CancellationToken.None, new FileDataStore("YouTubeKey")).Result;
}
return service;
}
//Create Stringbuilder to hold the data that will be exported to text file
StringBuilder sbuilBuilder = new StringBuilder();
//First foreach looop will run for all the country codes in countryCodes[Array]
/ It executes the YouTube services's Search module that allows us to fetch data for the given
search criteria and get the snippet information for 50 record. It filters it by country code
//Run the code for each country code provided in countryCodes variable
foreach (var countryCode in countryCodes) {
//We got 50 records based on our search criteria and we got their video
sbuilBuilder.Append(obj.Id
55
+ "\t" + obj.Snippet.ChannelTitle
+ "\t" + (obj.Snippet.PublishedAt.HasValue
? obj.Snippet.PublishedAt.Value.ToShortDateString() :
"null")
+ "\t" + cateName
+ "\t" + ReturTime(obj.ContentDetails.Duration)
+ "\t" + obj.Statistics.ViewCount
+ "\t" + (obj.ContentDetails.ContentRating != null ?
obj.ContentDetails.ContentRating.YtRating : null)
+ "\t" + obj.Statistics.CommentCount
+ "\t" + obj.Statistics.LikeCount
+ "\t" + countryCode
);
}
sbuilBuilder.Append(Environment.NewLine);
}
}
}
dictionary.Add(23, "Comedy");
dictionary.Add(24, "Entertainment");
dictionary.Add(25, "News & Politics");
dictionary.Add(26, "Howto & Style");
dictionary.Add(27, "Education");
dictionary.Add(28, "Science & Technology");
dictionary.Add(29, "Nonprofits & Activism");
return dictionary;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTubeTagExtraction;
namespace YouTubeTagExtraction
{
class Program
{
static void Main(string[] args)
{
//First function that will be executed.
//search Criteria to perform search on YouTube API
string searchCriteria = "Music";
}
}
}
57
BIBLIOGRAPHY
https://www.YouTube.com/yt/press/statistics.html.
[3] Datanami.com. 2016. Mining for YouTube Gold with Hadoop and Friends
https://www.datanami.com/2014/11/12/mining-YouTube-gold-hadoop-friends/.
[4] 3pillarglobal.com. 2016. How To Analyze Big Data With Hadoop Technologies
http://www.3pillarglobal.com/insights/analyze-big-data-hadoop-technologies
2016. http://www.cs.ubc.ca/nest/dbsl/intro.html.
nd
Implementation: The complete book, 2 edition. New Jersey: Prentice-Hall, Inc. 2009
[10] Ajinkya Ingle, Anjali Kante, Shriya Samak, Anita Kumari. 2005. Sentiment
[12] deRoos et al., Dirk. 2014. "Chapter 4 - Storing Data in Hadoop—The Hadoop
Distributed File System". Hadoop for Dummies. John Wiley & Sons.
http://share.edureka.co/pydio/data/public/hadoop
https://www.appcoda.com/YouTube-api-ios-tutorial/