Last active
July 14, 2020 16:40
-
-
Save SkaTeMasTer/867c9cc7105b2eb4f6ea93a84c370a2a to your computer and use it in GitHub Desktop.
Upload & Share the latest file to dropbox and email the share url...
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title></title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | |
</head> | |
<body style="margin: 0; padding: 0;"> | |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> | |
<tr> | |
<td style="padding: 15px 0 30px 0;"> | |
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc; border-collapse: collapse;"> | |
<tr> | |
<td align="center" bgcolor="#FFF" style="padding: 40px 0 3px 0; color: #153643; font-size: 28px; font-weight: bold; font-family: Arial, sans-serif;"> | |
<img src="somewhere.es/images/pir8-wsj-logo.png" alt="Creating Email Magic" width="576" height="147" style="display: block;" /> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding: 22px 23px 40px 30px;"> | |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> | |
<tr> | |
<td bgcolor="#eee" style="font-size: 24px;text-align:center;color:#555;font-size: 16pt; font-family: Times,Merriweather, Georgia, serif; font-weight: 500; letter-spacing: 11px;"> | |
<b>THE MORNING BRIEF</b> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding: 20px 0 30px 0; color: #222; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;"> | |
<div style=" background-color:#fafafa; | |
border: solid 1px #666; | |
border-radius: 12px; | |
box-sizing: border-box; | |
/*box-shadow: 0 0 15px 2px #444;*/ | |
color: #333; | |
display: inline-block; | |
margin-top: 15px; | |
width:100%; | |
padding: 35px 6px;"> | |
<div style=" padding-left:35px;padding-top:15px"> | |
<strong>Your daily newspaper has arrived!</strong> 📰 | |
<p style="padding:23px"> | |
Below is a link | |
to a digital replica of the print edition of:<br /> <b><u>The Wall Street Journal</u></b> newspaper. <br /> | |
<br /> It is delivered daily: Monday through Saturday. | |
<br /> | |
<br /> | |
You may read it in your browser or download the PDF file.</p> | |
</p> | |
<p>Enjoy!</p> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> | |
<tr> | |
<td width="260" valign="top"> | |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> | |
<tr> | |
<td> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding: 25px 0 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;"> | |
<div style="background-color: yellow; | |
border: solid 5px red; | |
border-radius: 12px; | |
box-sizing: border-box; | |
color: #3498db; | |
cursor: pointer; | |
display: inline-block; | |
font-size: 40px; | |
font-weight: bold; | |
margin: 0; | |
padding: 15px 15px; | |
color: red;"> | |
456464565646546 | |
</div> | |
</td> | |
</tr> | |
</table> | |
</td> | |
<td style="font-size: 0; line-height: 0;" width="20"> | |
| |
</td> | |
<td width="260" valign="top"> | |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> | |
<tr> | |
<td> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding: 25px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;"> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In tempus adipiscing felis, sit amet blandit ipsum volutpat sed. Morbi porttitor, eget accumsan dictum, nisi libero ultricies ipsum, in posuere mauris neque at erat. | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="#ee4c50" style="padding: 30px 30px 30px 30px;"> | |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> | |
<tr> | |
<td style="color: #ffffff; font-family: Arial, sans-serif; font-size: 14px;" width="75%"> | |
® Someone, somewhere 2013<br/> | |
<a href="#" style="color: #ffffff;"><font color="#ffffff">Unsubscribe</font></a> to this newsletter instantly | |
</td> | |
<td align="right" width="25%"> | |
<table border="0" cellpadding="0" cellspacing="0"> | |
<tr> | |
<td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;"> | |
<a href="http://www.twitter.com/" style="color: #ffffff;"> | |
<img src="https://s3-us-west-gf2.amazonaws.com/s.cdpn.io/210284/tw.gif" alt="Twitter" width="38" height="38" style="display: block;" border="0" /> | |
</a> | |
</td> | |
<td style="font-size: 0; line-height: 0;" width="20"> </td> | |
<td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;"> | |
<a href="http://www.twitter.com/" style="color: #ffffff;"> | |
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/fb.gif" alt="Facebook" width="38" height="38" style="display: block;" border="0" /> | |
</a> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
</body> | |
</html> |
This file contains hidden or 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/bash | |
# | |
# DESCRIPTION: A Torrent RSS feed matches keyword and downloads the file. Then watches a local directory for a | |
# newly downloaded torrent file. The file is then uploaded to Dropbox. Links to the online file | |
# are emailed to a list of people. | |
# | |
# (+) Local File => | |
# (+) Dropbox => | |
# (+) Share Link => | |
# | |
# REQUIREMENTS: | |
# + Dropbox API Wrapper | |
# (https://github.com/andreafabrizi/Dropbox-Uploader) | |
# | |
# + PDF to Image: | |
# (sudo apt-get install poppler-utils) | |
# | |
DROPBOXDIR="/_TempWSJ/" | |
FILETORRENTS="/home/user/Downloads/WSJ" | |
TMPDIR="/home/user/Downloads/WSJ-temp" | |
HOMEDIR="$HOME/WSJtoDropbox" | |
EMAILTO="[email protected],[email protected],[email protected]" | |
NOW=$(date +"%A, %b %-d") | |
echo "[Torrent Bot v1.01] --- Local File => Dropbox => Share Link => Email" | |
echo "---" | |
echo "" | |
echo "Looking for latest file from ${FILETORRENTS}..." | |
# get lastest file from download dir + remove carriage returng | |
SEARCHRESULT=$(ls -t "${FILETORRENTS}" | head -n 1 | sed -e 's/\r//g') | |
# create a new file to upload | |
#NEWFILENAME=$(date +"WSJ--[%b-%-d-%Y.%a].pdf") | |
#COPYFILE=$(cp "${FILETORRENTS}/${SEARCHRESULT}" "${FILETORRENTS}/${NEWFILENAME}") | |
#STANDARIZED="${FILETORRENTS}/${NEWFILENAME}" | |
#echo $NEWFILENAME | |
#echo $STANDARIZED | |
# Checks if file has size greater than 0 | |
if [ -s "${FILETORRENTS}/${SEARCHRESULT}" ]; then | |
echo "Download verified." | |
else | |
echo "Filesize is 0!!!!! download is in process..." | |
exit | |
fi | |
# if fileexists marker, exit | |
if [ -f "${TMPDIR}/${SEARCHRESULT}".uploaded ]; then | |
echo "File (${FILETORRENTS}/${SEARCHRESULT}) has already been uploaded!" | |
exit | |
fi | |
#-------------{{ | |
# wait for found file to finish download | |
echo "Found a new file uploaded!!! ..." | |
# create a new file to upload | |
#NEWFILENAME=$(date +"WSJ--[%b-%-d-%Y.%a].pdf") | |
#STANDARIZED=$(cp "${FILETORRENTS}/${SEARCHRESULT}" "${FILETORRENTS}/${NEWFILENAME}") | |
#echo $NEWFILENAME | |
#echo $STANDARIZED | |
echo "Cache Touching file to prevent duplicate files already uploaded..." | |
touch "${TMPDIR}/${SEARCHRESULT}".uploaded | |
#--------------}} | |
echo "SLEEPING to prevent race condition..." | |
sleep 160 | |
#__________________________________{{ begin PDF thumbnail rip}} | |
#-----[new code] | |
# ---- move to top of page | |
LOCALWEBDIR="/var/www/html/imagesWSJ" | |
IPWEBSERVER="ip31.i2-30.eu" | |
# ---------- | |
WWWTHUMBNAIL="http://${IPWEBSERVER}/imagesWSJ/${SEARCHRESULT}.jpg" | |
#----------------[move toalmost top and use] | |
FILENAMELOCATION="${FILETORRENTS}/${SEARCHRESULT}" | |
#--------------- | |
JPEGTHUMBNAIL="${LOCALWEBDIR}/${SEARCHRESULT}.jpg" | |
# create a image thumbnail from PDF | |
# using 'pdftoppm' util | |
# save write image to local webserver directory | |
PDF2IMG=$(pdftoppm -singlefile -f 1 -r 72 -jpeg "${FILETORRENTS}/${SEARCHRESULT}" > "${JPEGTHUMBNAIL}") | |
#------[ end new code]-------- | |
#__________________________________{{ end PDF thumbnail rip }} | |
echo "Dropbox Uploading..." | |
$HOMEDIR/dropbox_uploader.sh -f $HOMEDIR/.dropbox_uploader upload "${FILETORRENTS}/${SEARCHRESULT}" "${DROPBOXDIR}" | |
#echo ${MESSAGE/dl=0/dl=1} | |
echo "Dropbox share: getting link..." | |
# retrive a link to open the file on dropbox (ends in ...?dl=0) | |
SHARELINK=$($HOMEDIR/dropbox_uploader.sh -q -f $HOMEDIR/.dropbox_uploader share "${DROPBOXDIR}${SEARCHRESULT}") | |
# convert open link (?dl=0) to a download link (dl=1) | |
DOWNLOADLINK=${SHARELINK/dl=0/dl=1} | |
echo "Fetching RSS Feed..." | |
# https://www.wsj.com/news/rss-news-and-feeds | |
# get RSS feed -- RSS-WSJ.html | |
GETFEED=$(./fetchRSS-WSJ.sh) | |
# --- | |
echo "Finding National Geographics Photo of the day ..." | |
# get data | |
data=$(curl -s https://www.nationalgeographic.com/photography/photo-of-the-day/) | |
if [ -n "$data" ] | |
then | |
# get img url | |
imgurl=$(grep 'property="og:image"' <<< "$data") | |
imgurl="$(cut -d"\"" -f4 <<< $imgurl)" | |
# imgdescription=$(grep 'property="og:description"' <<< "$data") | |
# imgdescription="$(cut -d"\"" -f4 <<< $imgdescription)" | |
#echo ${imgdescription} | |
echo "${imgurl}" | |
# imgcanonical=$(grep 'property="og:url"' <<< "$data") | |
# imgcanonical="$(cut -d"\"" -f4 <<< $imgcanonical)" | |
else | |
echo "NatGeo: connection failed" | |
fi | |
# --- | |
echo "Sending Email..." | |
ARG_EMAIL_FROM="WSJ Bot ([email protected])" | |
ARG_EMAIL_SUBJECT="\"The Wall Street Journal\" for ${NOW} 🗞️ " | |
send_email () { | |
( | |
echo "To: $1" | |
echo "From: ${ARG_EMAIL_FROM}" | |
echo "Subject: ${ARG_EMAIL_SUBJECT}" | |
echo "Mime-Version: 1.0" | |
echo "Content-Type: text/html; charset='utf-8'" | |
echo | |
cat header.html | |
echo "<b><p><center><h1> <a href='${SHARELINK}' target='_blank'>Read Today's Paper</a> </b></p> </h1></center>" | |
# direct download link | |
echo "<center><b><h1><a href='${DOWNLOADLINK}' target='_blank'>Download Document File</a> </b></center><br /></h1>" | |
echo "<a href='${WWWTHUMBNAIL}' target='_blank'>" | |
echo "<img src='${WWWTHUMBNAIL}' width='95%' height='95%' alt='paper thumb' title='front page' style='display:block' />" | |
echo " </a>" | |
# RSS FEED | |
echo "<em><h2>Trending Headlines</h2></em>" | |
cat RSS-WSJ.html | |
# NatGeo Photo | |
echo "<center><br /><br /><small>National Geographic's Photo of the Day</small>" | |
echo " <p> <a href='${imgurl}' target='_blank'><img src='${imgurl}' alt='NetGeo Photo of the day' title='NatGeo' style='display:block' width='90%' height='90%' /></a>" | |
echo "</p></center> <br />" | |
cat footer.html | |
) | /usr/sbin/ssmtp $1 | |
} | |
for i in $(echo $EMAILTO | sed "s/,/ /g") | |
do | |
echo "Emailing $i ..." | |
send_email $i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment