import java.io.BufferedReader;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.Reader;import java.io.StringWriter;import java.io.UnsupportedEncodingException;import java.io.Writer;import java.net.URI;import java.net.URISyntaxException;import java.util.ArrayList;import java.util.List;import java.util.Scanner;import java.util.logging.Formatter;import java.util.logging.Handler;import java.util.logging.Level;import java.util.logging.LogRecord;import java.util.logging.Logger;import java.util.regex.Pattern;import org.apache.http.HttpEntity;import org.apache.http.HttpResponse;import org.apache.http.NameValuePair;import org.apache.http.client.CookieStore;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpGet;import org.apache.http.client.protocol.ClientContext;import org.apache.http.client.utils.URIUtils;import org.apache.http.client.utils.URLEncodedUtils;import org.apache.http.impl.client.BasicCookieStore;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.message.BasicNameValuePair;import org.apache.http.protocol.BasicHttpContext;import org.apache.http.protocol.HttpContext;public class JavaYoutubeDownloader { public static String newline = System.getProperty("line.separator"); private static final Logger log = Logger.getLogger(JavaYoutubeDownloader.class.getCanonicalName()); private static final Level defaultLogLevelSelf = Level.FINER; private static final Level defaultLogLevel = Level.WARNING; private static final Logger rootlog = Logger.getLogger(""); private static final String scheme = "http"; private static final String host = "www.youtube.com"; private static final Pattern commaPattern = Pattern.compile(","); private static final Pattern pipePattern = Pattern.compile("\|"); private static final char[] ILLEGAL_FILENAME_CHARACTERS = { '/', 'n', 'r', 't', ' ', 'f', '`', '?', '*', '\', '', '|', '"', ':' }; private static void usage(String error) { if (error != null) { System.err.println("Error: " + error); } System.err.println("usage: JavaYoutubeDownload VIDEO_ID DESTINATION_DIRECTORY"); System.exit(-1); } public static void main(String[] args) { if (args == null || args.length == 0) { usage("Missing video id. Extract from http://www.youtube.com/watch?v=VIDEO_ID"); } try { setupLogging(); log.fine("Starting"); String videoId = null; String outdir = "."; // TODO Ghetto command line parsing if (args.length == 1) { videoId = args[0]; } else if (args.length == 2) { videoId = args[0]; outdir = args[1]; } int format = 18; // http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs String encoding = "UTF-8"; String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13"; File outputDir = new File(outdir); String extension = getExtension(format); play(videoId, format, encoding, userAgent, outputDir, extension); } catch (Throwable t) { t.printStackTrace(); } log.fine("Finished"); } private static String getExtension(int format) { // TODO return "mp4"; } private static void play(String videoId, int format, String encoding, String userAgent, File outputdir, String extension) throws Throwable { log.fine("Retrieving " + videoId); List
* Exploded results from get_video_info: * * fexp=90... * allow_embed=1 * fmt_stream_map=35|http://v9.lscache8... * fmt_url_map=35|http://v9.lscache8... * allow_ratings=1 * keywords=Stefan Molyneux,Luke Bessey,anarchy,stateless society,giant stone cow,the story of our unenslavement,market anarchy,voluntaryism,anarcho capitalism * track_embed=0 * fmt_list=35/854x480/9/0/115,34/640x360/9/0/115,18/640x360/9/0/115,5/320x240/7/0/0 * author=lukebessey * muted=0 * length_seconds=390 * plid=AA... * ftoken=null * status=ok * watermark=http://s.ytimg.com/yt/swf/logo-vfl_bP6ud.swf,http://s.ytimg.com/yt/swf/hdlogo-vfloR6wva.swf * timestamp=12... * has_cc=False * fmt_map=35/854x480/9/0/115,34/640x360/9/0/115,18/640x360/9/0/115,5/320x240/7/0/0 * leanback_module=http://s.ytimg.com/yt/swfbin/leanback_module-vflJYyeZN.swf * hl=en_US * endscreen_module=http://s.ytimg.com/yt/swfbin/endscreen-vflk19iTq.swf * vq=auto * avg_rating=5.0 * video_id=S6IZP3yRJ9I * token=vPpcFNh... * thumbnail_url=https://www.euvolution.com/futurist-transhuman-news-blog/wp-content/uploads/2018/06/766e4df312efault.jpg.jpg * title=The Story of Our Unenslavement - Animated *
*/
See the original post here:
How to download videos from youtube on java? - Stack Overflow
- Quietism and Activism | On the Mark [Last Updated On: March 6th, 2018] [Originally Added On: March 6th, 2018]
- Panarchy - Wikipedia [Last Updated On: March 10th, 2018] [Originally Added On: March 10th, 2018]
- Free Advice [Last Updated On: April 6th, 2018] [Originally Added On: April 6th, 2018]
- Markets - Casey Research [Last Updated On: April 6th, 2018] [Originally Added On: April 6th, 2018]
- Use volunteer in a sentence | volunteer sentence examples [Last Updated On: May 7th, 2018] [Originally Added On: May 7th, 2018]
- Christianarchism | the bastion of Christian anarchism! [Last Updated On: May 12th, 2018] [Originally Added On: May 12th, 2018]
- The Atlantean Conspiracy [Last Updated On: May 15th, 2018] [Originally Added On: May 15th, 2018]
- Southwest Pilot Was As Cool As A Cucumber During Engine ... [Last Updated On: June 15th, 2018] [Originally Added On: June 15th, 2018]
- Unschooling - Wikipedia [Last Updated On: July 5th, 2018] [Originally Added On: July 5th, 2018]
- Individual - Wikipedia [Last Updated On: July 5th, 2018] [Originally Added On: July 5th, 2018]
- Questions for Head of Department Interview | One Damn Thing [Last Updated On: July 13th, 2018] [Originally Added On: July 13th, 2018]
- The Right and Wrong of Compulsion by the State and Other ... [Last Updated On: July 15th, 2018] [Originally Added On: July 15th, 2018]
- News - WendyMcElroy.com [Last Updated On: August 5th, 2018] [Originally Added On: August 5th, 2018]
- Voluntaryism In Action: Fairy Tale Park In Oregon Gets A ... [Last Updated On: September 26th, 2018] [Originally Added On: September 26th, 2018]
- What is a Voluntaryist? - Zero Aggression Project [Last Updated On: November 21st, 2018] [Originally Added On: November 21st, 2018]
- Do it yourself - Wikipedia [Last Updated On: December 8th, 2018] [Originally Added On: December 8th, 2018]
- Voluntarism | Define Voluntarism at Dictionary.com [Last Updated On: February 16th, 2019] [Originally Added On: February 16th, 2019]
- Amazon.com: Customer reviews: The God of Atheists [Last Updated On: February 23rd, 2019] [Originally Added On: February 23rd, 2019]
- Quick and Clean: 40 Non-Processed Snacks That Meet Your ... [Last Updated On: March 8th, 2019] [Originally Added On: March 8th, 2019]
- Free State Project - Wikipedia [Last Updated On: March 8th, 2019] [Originally Added On: March 8th, 2019]
- The Voluntaryist [Last Updated On: April 26th, 2019] [Originally Added On: April 26th, 2019]
- Hatzalah - Wikipedia [Last Updated On: May 11th, 2019] [Originally Added On: May 11th, 2019]
- Introduction to Voluntaryism - The Art of Not Being Governed [Last Updated On: May 19th, 2019] [Originally Added On: May 19th, 2019]
- The Panarchist Solution to a World Divided - CounterPunch [Last Updated On: December 21st, 2019] [Originally Added On: December 21st, 2019]
- Bear Lake Hill Climbs were a success | News-Examiner - The Herald Journal [Last Updated On: February 12th, 2020] [Originally Added On: February 12th, 2020]
- Satyaniti and Swaraj constitute the historical backbone of India - Global News Hut [Last Updated On: March 26th, 2020] [Originally Added On: March 26th, 2020]
- Satyaniti and Swaraj constitute the historical backbone of the socio-political order of India, through the ages - OpIndia [Last Updated On: March 26th, 2020] [Originally Added On: March 26th, 2020]
- Satyaniti and Swaraj: The True Twin Pillars Of Society - Youth Ki Awaaz [Last Updated On: March 26th, 2020] [Originally Added On: March 26th, 2020]
- Black Friday Is Capitalism at Its Most Beautiful | Cole Webb Harter - Foundation for Economic Education [Last Updated On: July 30th, 2020] [Originally Added On: July 30th, 2020]
- Led Zeppelins Jimmy Page revealed the song that changed his life - Far Out Magazine [Last Updated On: August 8th, 2020] [Originally Added On: August 8th, 2020]
- What you need to know for Thursday, August 6 - Lompoc Record [Last Updated On: August 8th, 2020] [Originally Added On: August 8th, 2020]
- Rocket Propulsion Market 2020: Overview and Share Forecasted to 2027 - Market Research Posts [Last Updated On: August 8th, 2020] [Originally Added On: August 8th, 2020]
- Voluntaryism | Polcompball Wiki | Fandom [Last Updated On: October 8th, 2020] [Originally Added On: October 8th, 2020]
- voluntaryist.com - Fundamentals of Voluntaryism [Last Updated On: October 8th, 2020] [Originally Added On: October 8th, 2020]
- Black Friday Is Capitalism at Its Most Beautiful | Cole Webb Harter - Foundation for Economic [Last Updated On: December 5th, 2020] [Originally Added On: December 5th, 2020]
- Communism Quotes (1054 quotes) - Goodreads [Last Updated On: November 13th, 2021] [Originally Added On: November 13th, 2021]
- Frdric Bastiat Quotes (Author of The Law) [Last Updated On: November 13th, 2021] [Originally Added On: November 13th, 2021]
- Private police in the United States - Wikipedia [Last Updated On: October 19th, 2022] [Originally Added On: October 19th, 2022]
- Alexis de Tocqueville Quotes (Author of Democracy in America) - Goodreads [Last Updated On: October 19th, 2022] [Originally Added On: October 19th, 2022]
- Anarchist symbolism - Wikipedia [Last Updated On: October 27th, 2022] [Originally Added On: October 27th, 2022]
- Richard Epstein - Wikipedia [Last Updated On: October 27th, 2022] [Originally Added On: October 27th, 2022]
- Portal:Libertarianism - Wikipedia [Last Updated On: October 27th, 2022] [Originally Added On: October 27th, 2022]
- Frdric Bastiat Quotes (Author of The Law) - Goodreads [Last Updated On: October 27th, 2022] [Originally Added On: October 27th, 2022]
- Jeff Bezos' Housekeeper Says She Had to Climb Out the Window to Use the Bathroom [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- China Plans to Send Monkeys to Space Station to Have Sex With Each Other [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Huge Drone Swarm to Form Giant Advertisement Over NYC Skyline [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Hackers Just Took Down One of the World's Most Advanced Telescopes [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- AOC Says Her Twitter Account Broke After She Made Fun of Elon Musk [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Chinese Spaceplane Releases Mystery Object Into Orbit [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- That "Research" About How Smartphones Are Causing Deformed Human Bodies Is SEO Spam, You Idiots [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Elon Musk Meeting With Advertisers, Begging Them Not to Leave Twitter [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- US Gov to Crack Down on "Bossware" That Spies On Employees' Computers [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- This Deepfake AI Singing Dolly Parton's "Jolene" Is Worryingly Good [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Scientists Found a Way to Control How High Mice Got on Cocaine [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Scientists Spot "Stripped, Pulsating Core" of Star Caused By Horrific Accident [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Manslaughter Case Has a Strange Twist: Tesla That Killed Couple Was on Autopilot [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Twitter Working on Plan to Charge Users to Watch Videos [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Scientists Use Actual Lunar Soil Sample to Create Rocket Fuel [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Cats May Be Tampering With Crime Scenes, Scientists Say [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- NASA Sets Launch Date for Mission to $10 Quintillion Asteroid [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Greta Thunberg Says UN Climate Conference Is a Scam and She's Not Attending [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- There's Something Strange About How These Stars Are Moving, Scientists Say [Last Updated On: November 4th, 2022] [Originally Added On: November 4th, 2022]
- Amazing Map Lets You Scroll Through the Entire Known Universe [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- NASA Tells Astronauts That Tweeting Isn't As Important as Staying Alive [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Ticketmaster May Have Finally Met Its Match: Furious Swifties [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- So Many People Are Using a Diabetes Drug for Weight Loss That Actual Diabetics Are Having Trouble Getting It [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Twitter Claims Video of Moon Rocket Launch Is Revenge Porn [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Experts Excoriate NASA Report Claiming James Webb Wasn't Homophobic [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Behind the Lawsuit Against Celebs Who Shilled FTX Before Its Spectacular Meltdown [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Elon Musk Locks Twitter Employees Out Office, Then Asks Them to Meet Him on the 10th Floor [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- "Elon" Plummets in Popularity as a Baby Name for Some Reason [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Experts Baffled by Why NASA’s “Red Crew” Wear Blue Shirts [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Startup Says It's Building a Giant CO2 Battery in the United States [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Panicked Elon Musk Reportedly Begging Engineers Not to Leave [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Celebrities' Bored Apes Are Hilariously Worthless Now [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Sam Bankman-Fried Admits the "Ethics Stuff" Was "Mostly a Front" [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- NASA Drops Stunning New James Webb Image of a Star Being Born [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Celebrities Are Officially Being Sued by FTX Retail Investors [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- Former Facebook Exec Says Zuckerberg Has Surrounded Himself With Sycophants [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]
- NASA Orders Press Not to Photograph Launch Site After Moon Mission Takes Off [Last Updated On: November 20th, 2022] [Originally Added On: November 20th, 2022]