This commit is contained in:
Joe Steele
2024-06-25 09:14:51 -04:00
parent 3c44e940e2
commit c6af16b186
+55 -7
View File
@@ -1008,10 +1008,11 @@ def post_facebook3(title, content,headers, date, rating, address, picslist, loca
wpurl = attrib_list[0].wpurl
if wpurl and (attrib_list[0].picsLocalpath != '[]'):
if business_url:
status_message = str(title) + ': My Review - '+ wpurl + '\n Business website: '+ \
business_url+' \n\n'+ content
status_message = (
f'{str(title)}: My Review - {wpurl} \n Business website: {business_url}'\
+ ' \n\n') + content
else:
status_message = str(title) + ': My Review - '+ wpurl +' \n\n'+ content
status_message = f'{str(title)}: My Review - ' + wpurl + ' \n\n' + content
for img in img_list:
if 'montage.mp4' in img:
imgs_vid.append(img.strip())
@@ -1176,13 +1177,12 @@ def post_to_instagram2(title, content, headers, date, rating, address, picslist,
Returns:
bool: True if the post was successfully uploaded, False otherwise.
"""
outputmontage = ''
addresshtml = re.sub(" ", ".",address)
attrib_list = local_outputs['postssession'].query(Posts).filter(Posts.name == title).all()
business_url = attrib_list[0].businessurl
wpurl = attrib_list[0].wpurl
if wpurl:
if business_url:
if wpurl := attrib_list[0].wpurl:
if business_url := attrib_list[0].businessurl:
data = title + "\n"+ address+"\n"+business_url+"\n"+"Review: "+wpurl+\
"\nGoogle map to destination: " \
r"https://www.google.com/maps/dir/?api=1&destination="\
@@ -1502,6 +1502,18 @@ def post_to_wordpress(title,content,headers,date,rating,address,picslist,local_o
##################################################################################################
def build_picslist(picchop, piclink):
"""
Builds a list of pictures for posting based on the provided picture links.
Args:
picchop (list): List of picture links to process.
piclink (str): The picture link to be added to the list.
Returns:
str: A string containing the formatted list of pictures for posting.
Raises:
AttributeError: If an error occurs during picture processing.
"""
for piclink in picchop:
if piclink != '':
@@ -1529,6 +1541,19 @@ def build_picslist(picchop,piclink):
##################################################################################################
def get_wordpress_post_date_string(date_string, date):
"""
Parses a date string and returns two formatted date strings.
Args:
date_string (str): The input date string to be parsed.
date (str): The keyword indicating the date offset.
Returns:
tuple: A tuple containing two formatted date strings.
Raises:
AttributeError: If an error occurs during date parsing.
"""
if "a day" in date_string:
date = dt.timedelta(days=-1)
@@ -1589,6 +1614,29 @@ def get_wordpress_post_date_string(date_string,date):
##################################################################################################
def create_wordpress_post(newdate2, picchop, title, address, headers, post_id, linkslist, local_outputs, content, googleadress, rating, featured_photo_id):
"""
Creates a WordPress post with pictures and content.
Args:
newdate2: The date of the post.
picchop (list): List of picture links to process.
title: The title of the post.
address: The address associated with the post.
headers: The headers for the HTTP request.
post_id: The ID of the post.
linkslist: List of links to pictures.
local_outputs: Local outputs for the post.
content: The content of the post.
googleadress: The Google address for the post.
rating: The rating of the post.
featured_photo_id: The ID of the featured photo.
Returns:
bool: True if the post creation is successful, False otherwise.
Raises:
AttributeError: If an error occurs during post creation or processing.
"""
if not post_id:
googleadress = r"<a href=https://www.google.com/maps/dir/?api=1&destination="+addresshtml\
+ r">"+address+r"</a>"