Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #set -xv
- # Version 1.2
- #***********************************************************NOTES *************************************************************************#
- # If you're using FireFox install the addon: Copy Urls Expert. #
- # If you're using Chrome install the extension: Copy All Urls. #
- # Simply browse any number of myfont pages in FireFox or Chrome. When done, simply copy all tab urls using one of the above addons #
- # (doesn't matter if you got tabs open that are NOT myfonts! the script file will cleanse them!). #
- # Paste the links in tab.txt (Ctrl+V) and then run mtfontrip.sh which will download the woff files and convert them to both woff and ttf. #
- # #
- # 20 web font previews are allowed if you are NOT signed in. #
- # 50 web font previews are allowed if you ARE signed in. #
- # #
- # wuts great is u can always create new IDs (username/passwords) without the hassle of providing REAL emails! #
- # so then just export the cookie.txt file for each user and use them! :) #
- # #
- # Go here first to generate a random English name+surname #
- # http://www.behindthename.com/random/random.php?number=1&gender=m&surname=&randomsurname=yes&all=no&usage_eng=1 #
- # #
- # Then here to create a new myfonts user account #
- # https://www.myfonts.com/secure/newuser/ #
- # #
- # Enter like the below example #
- # Your name Sanford Howe #
- # Email address howe56@gmail.com #
- # Password howe56 #
- # Password again howe56 #
- # #
- # Then install this #
- # http://wiert.me/2011/05/30/exporting-google-chrome-cookies-for-wget-usage-cookie-txt-export-google-chrome-extension-gallery/ #
- # click the button to see cookie info then Ctrl+A, Ctrl+C it then Ctrl+V it in a new txt file and name it wutever (ie. howe56.txt) #
- # then Ctrl+D the wget line in myfontrip.sh and rename the previous cookie txt file to the new one. ie. #
- # sed "s/.*/wget --load-cookies howe56.txt -P MyFonts\/ &webfont_preview.html/" myfonts_html.txt > myfonts_html.bat #
- # Make sure u got ur myfont links in tab.txt and you can simply run myfontrip.sh! #
- #***********************************************************NOTES *************************************************************************#
- #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SET VARIABLES :::::::::::::::::::::::::::::::::::::::::::::::::::::
- export BINDIR=~/bin/MyFontDownloader/bin
- export TTFTEMP=~/bin/MyFontDownloader/bin/MyFonts
- export TTFTARGET=~/Fonts_Other/font-unarchive/merlin
- export FILEMAN=thunar
- PATH=/usr/local/bin:$PATH
- FONTFORGE_LANGUAGE=ff
- export PATH FONTFORGE_LANGUAGE
- #
- # LETS START!!
- #
- #Change to bin Directory
- cd $BINDIR
- #
- # delete all lines NOT containing myfonts links from tabs.txt
- sed '/myfonts\.com\/fonts/!d' tabs.txt > myfonts_html.txt
- cat myfonts_html.txt | sort -u > myfonts_html1.txt
- rm myfonts_html.txt
- mv myfonts_html1.txt myfonts_html.txt
- # Convert Dos Line Endings to Unix Format
- sed 's/.$//' myfonts_html.txt
- #:::::::::::::::::::::::::::::::::::::::: CHOOSE COOKIE OPTIONS ::::::::::::::::::::::::::::::::::::::::
- #
- # ============================ WITH COOKIES (Better)===================================================
- #********NOTE************
- # I was unable to figure out how to use the $TTFTEMP variable in this command. (Won't expant properly) So these are the only commands with hard-coded paths.
- # uncomment only the line with the cookie u want to use
- sed 's/\(^.*\)/wget --load-cookies cookies\/harve67.txt -PMyFonts\/ \1webfont_preview.html/' myfonts_html.txt > myfonts_html.sh
- # sed 's/\(^.*\)/wget --load-cookies cookies\/hamm45.txt -PMyFonts\/ \1webfont_preview.html/' myfonts_html.txt > myfonts_html.sh
- # sed 's/\(^.*\)/wget --load-cookies cookies\/croberts119.txt -PMyFonts\/ \1webfont_preview.html/' myfonts_html.txt > myfonts_html.sh
- # Format Script to Bash and Enable
- echo '#!/bin/bash
- set -x' | cat - myfonts_html.sh > temp && mv temp myfonts_html.sh
- chmod +x myfonts_html.sh
- # ============================ WITHOUT COOKIES =========================================================
- # uncomment all lines in section and don't forget to comment out the lines in the "with coockies" section above
- # sed "s/.*/wget -PMyFonts\/ &webfont_preview.html/" myfonts_html.txt > myfonts_html.sh
- # Format Script to Bash and Enable
- # echo '#!/bin/bash
- # set -x' | cat - myfonts_html.sh > temp && mv temp myfonts_html.sh
- # chmod +x myfonts_html.sh
- #:::::::::::::::::::::::::::::::::::::::: EXECUTE THE BASH SCRIPT FILE THAT WILL DOWNLOAD ALL THE HTML FILES ::::::::::::::::::::::::::::::
- ./myfonts_html.sh
- # concatenate all html files into 1 big txt file
- find "$TTFTEMP"/ -type f -print0 | sort -z | xargs -0 cat > allhmtls.txt
- # Clean up
- find "$TTFTEMP"/ -type f -delete
- #:::::::::::::::::::::::::::::::::::::::: PROCESSING HTMLs TO GET THE CSS LINKS ::::::::::::::::::::::::::::::::::::::::
- # delete all lines NOT containing the word easy
- sed '/easy\.myfonts\.net/!d' allhmtls.txt > myfonts_css.txt
- # clean it up...
- sed -i "s/<link.*\/\/\|'>//g" myfonts_css.txt
- # add curl command
- sed -i 's/.*/curl -o MyFonts\/cssxplaceholder &/' myfonts_css.txt
- # now we have to put a counter to each css file so they dont get overwritten!
- perl -ple 's/placeholder/$n++/e' myfonts_css.txt > myfonts_css.sh
- # Format Script to Bash and Enable
- echo '#!/bin/bash
- set -x' | cat - myfonts_css.sh > temp && mv temp myfonts_css.sh
- chmod +x myfonts_css.sh
- #:::::::::::::::::::::::::::::::::::::::: EXECUTE THE BASH FILE THAT WILL DOWNLOAD ALL THE CSS FILES ::::::::::::::::::::::::::::::::::::::::
- ./myfonts_css.sh
- # concatenate all css files into 1 big txt file
- find "$TTFTEMP"/ -type f -print0 | sort -z | xargs -0 cat > allcss.txt
- # Clean up
- find "$TTFTEMP"/ -type f -delete
- # remove all of the base fonts
- sed "/Rooney\|ClickBits\|Network/d" allcss.txt > lesscss.txt
- #:::::::::::::::::::::::::::::::::::::::: PROCESSING CSSs TO GET THE FONT LINKS ::::::::::::::::::::::::::::::::::::::::
- # now we start matching the ttf font links
- grep -o -P "(v[0-9]/ttf)(.*?)(?=\))" lesscss.txt > myfonts_font.txt
- # add curl command
- sed -i "s/.*/curl -o MyFonts\/fontxplaceholder 'easy.myfonts.net\/&'/" myfonts_font.txt
- sed -i "s/'/\"/g" myfonts_font.txt
- # now we have to put a counter to each font file so they dont get overwritten!
- perl -ple 's/placeholder/$n++/e' myfonts_font.txt > myfonts_font.sh
- # Format Script to Bash and Enable
- echo '#!/bin/bash
- set -x' | cat - myfonts_font.sh > temp && mv temp myfonts_font.sh
- chmod +x myfonts_font.sh
- #:::::::::::::::::::::::::::::::::::::::: EXECUTE THE BASH FILE TO RETRIEVE FONTS & PROCESS ::::::::::::::::::::::::::::::::::::::::
- ./myfonts_font.sh
- # Rename to .ttf Files
- find "$TTFTEMP"/ -type f -print0 | xargs -0 -I{} mv "{}" "{}".ttf
- # this will reencode the fonts to utf8, which we can then convert to otf using transtype pro 3 if we wish
- ./convert2ttf
- #::::::::::::::::::::::::::::::::::::::::: CLEANUP ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- # Clean Up temp fonts
- rm "$TTFTEMP"/fontx*.ttf
- #find "$TTFTEMP"/*.ttf -regextype posix-extended -regex '^(.*[^_][^0-9]{1,2}\.ttf)' -delete
- # remove the _numbers from the font filenames. Any fonts left with trailing rm allcss.txt allhmtls.txt myfonts_css.sh myfonts_css.txt myfonts_html.txt myfonts_html.sh myfonts_font.sh myfonts_font.txtnumbers in the filenames (fontname_##.ttf) are duplicates
- rename 's/_\d+\././' $TTFTEMP/*.ttf
- # cleanup gererated files (everything BUT lesscss.txt!!!!)
- rm allcss.txt allhmtls.txt myfonts_css.sh myfonts_css.txt myfonts_html.txt myfonts_html.sh myfonts_font.sh myfonts_font.txt
- # here we empty tabs.txt to signify that we are done with those fonts. im placing this at the very end of the script so that if no fonts were downloaded i can quit the procedure b4 hand
- sed -i "s/.*//g" tabs.txt
- sed -i "/^\s*$/d" tabs.txt
- #:::::::::::::::::::::::::::::::::::::::::: POST PROCCESSING ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- # Move Fonts to their final destination
- mv $TTFTEMP/*.ttf $TTFTARGET
- #:: ALL DONE!!! CHECK THE TTFTARGET FOLDER FOR THE FONTS!!! or have these commands do it for u :)
- $FILEMAN $TTFTARGET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement