Last active
June 23, 2019 08:43
-
-
Save Norod/8796aab4e11d3c149c54d45a3c565c11 to your computer and use it in GitHub Desktop.
How to extract a list of Youtube links from a Facebook discussion thread and generate a playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# How to extract a list of Youtube links from a Facebook discussion thread and generate a playlist | |
# ------------------------------------------------------------------------------------------------ | |
# By Doron Adler, @Norod78 | |
# | |
# Open the relevant comment thread in Facebook by tapping on the time next to the privacy indicator | |
# Save the relevant comment thread locally as a single “HTML only” file, call it "noalp.htm" | |
# Open your bash command line terminal, cd to the folder where you saved noalp.htm and paste the following: | |
grep -o -e 'https%3A%2F%2F\S*' "noalp.htm" > urlencoded.txt | |
cat ./urlencoded.txt | perl -pe 's/\%(\w\w)/chr hex $1/ge' > ./urldecoded.txt | |
cat ./urldecoded.txt | cut -f 1 -d ";" | cut -f 1 -d "&" | grep youtu | sed 's/&//g' | sort | uniq > youtu.txt | |
# The file youtu.txt contains a list of all Youtube links from that thread | |
# Now let's make a Playlist, based on these instructions: https://webapps.stackexchange.com/a/106340 | |
# paste the following: | |
linkList=$(grep -o 'v=.*' youtu.txt | cut -f2 -d"="| tr '\n' ',') | |
linkList2=$(grep 'youtu.be' youtu.txt | cut -f 1 -d "?" | cut -f4 -d"/" | tr '\n' ',') | |
playlistURL="http://www.youtube.com/watch_videos?video_ids=$linkList$linkList2" | |
echo "You can already enjoy your playlist at $playlistURL" | |
echo "However, there are a few more steps to make it propper" | |
open "$playlistURL" | |
# Now comes the part where you make this into a sharable public playlist | |
# Go to the playlist URL that your browser went to after you opened the generated | |
# playlist. It should look something like | |
# https://www.youtube.com/watch?v=[First video]&list=[PLAYLIST ID] | |
# Edit the link so it would look like this: | |
# https://www.youtube.com/playlist?list=[PLAYLIST ID]&disable_polymer=true | |
# Press the three dots to the right of the playlist title, and then select "Add all to..." | |
# Add the videos to your own playlist. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment