From 55dfec90df6507c5eb97b218986262a286e6c953 Mon Sep 17 00:00:00 2001 From: Joe Steele Date: Mon, 17 Jun 2024 17:27:39 -0400 Subject: [PATCH] more linting --- social.py | 90 +++++++++++++++++++------------------------------------ 1 file changed, 31 insertions(+), 59 deletions(-) diff --git a/social.py b/social.py index 0fec4e1..2ee17ea 100644 --- a/social.py +++ b/social.py @@ -6,21 +6,21 @@ import pathlib #from selenium.webdriver.chrome.service import Service import re #from openpyxl import Workbook, load_workbook -import pandas as pd from datetime import datetime -from dateutil.relativedelta import relativedelta import ast import base64 -import requests import datetime as dt +from urllib.request import urlretrieve +import requests #import json import jsonpickle -from urllib.request import urlretrieve import urllib3 #Instgram #from instapy import InstaPy #import instapy #from instabot import Bot +import pandas as pd +from dateutil.relativedelta import relativedelta from openpyxl import load_workbook import instagrapi #from instagrapi.types import StoryMention, StoryMedia, StoryLink, StoryHashtag @@ -34,11 +34,8 @@ from selenium.common.exceptions import NoSuchElementException #from selenium.webdriver.chrome.service import Service #twitter import tweepy - #import asyncio #import aiohttp - - import sqlalchemy #from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base @@ -605,7 +602,7 @@ def write_to_xlsx2(data, local_outputs): print("Encode Object into JSON formatted Data using jsonpickle") jsonposts = jsonpickle.encode(local_outputs['posts'], unpicklable=False) for processrow in df2.values: - if (processrow[1] in df.values): + if processrow[1] in df.values: print (' Row ',processrow.id,' ', processrow.name ,' already in XLS sheet') d2_row = Posts(name=processrow.name ,comment=processrow.comment,rating=\ processrow.rating,picsURL=processrow.picsURL,pics_local_path=processrow.\ @@ -875,7 +872,7 @@ def get_wordpress_featured_photo_id(post_id): ################################################################################################## -def post_to_x2(title, content, headers,date, rating, address, picslist,local_outputs): +def post_to_x2(title, content, headers,date, rating, address, picslist,local_outputs): """ Post to x2. @@ -918,12 +915,13 @@ def post_to_x2(title, content, headers,date, rating, address, picslist,local_out try: video_path = imgs_vid[0] # Message to post along with the video - attrib_list = local_outputs['postssession'].query(Posts).filter(Posts.name == title).all() + 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: # Don't post of website URL does not exist yet if business_url: #Sometimes Business URL does not exist, so account for it - status_message = str(title) + ': My Review - '+ wpurl + '\n Business website: '+ \ + status_message=str(title)+': My Review - '+wpurl+'\n Business website: '+\ business_url + '\n' else: status_message = str(title) + ': My Review - '+ wpurl + '\n' @@ -1001,7 +999,7 @@ def post_facebook3(title, content,headers, date, rating, address, picslist, loca return False time.sleep(env.facebooksleep) print(' Facebook response: ',post_id) - return (True) + return True ################################################################################################## @@ -1043,7 +1041,7 @@ def post_to_threads2(title, content, headers, date, rating, address, picslist, l return False -####################################################################################################### +################################################################################################### def post_to_tiktok(title, content, headers, date, rating, address, picslist, local_outputs): """ @@ -1126,41 +1124,11 @@ def post_to_instagram2(title, content, headers,date, rating, address, picslist,l if picslist != '[]' and "montage.mp4" in picslist: #content = content + get_hastags(address, title) pics = ((picslist[1:-1].replace(",","")).replace("'","")).split(" ") - video, outputmontage = make_montage_video_from_google(pics) try: instasession.video_upload(outputmontage, data) - # video2 = instasession.video_upload(outputmontage, data) except AttributeError as error: print(" An error occurred uploading video to Instagram:", type(error).__name__) return False - #media_pk = instasession.media_pk_from_url('https://www.instagram.com/p/CGgDsi7JQdS/') - #media_path = instasession.video_download(media_pk) - # joeeatswhat = instasession.user_info_by_username('timberjoe') - # try: buildout = instagrapi.story.StoryBuilder(outputmontage,'Credits @timberjoe',[StoryMention(user=joeeatswhat)]).video(40) # seconds - # except AttributeError as error: - # print(" An error occurred uploading video to Instagram:", type(error).__name__) # An error occurred: - # try: instasession.video_upload_to_story(buildout.path,"Credits @example",mentions=buildout.mentions,links=[StoryLink(webUri='https://www.joeeatswhat.com')],medias=[StoryMedia(media_pk=outputmontage)]) - # try: - # instasession.video_upload_to_story( - # outputmontage, - # "Credits @joeeatswhat", - # # mentions=[StoryMention(user='timberjoe', x=0.49892962, y=0.703125, width=0.8333333333333334, height=0.125)], - # links=[StoryLink(webUri='https://www.joeeatswhat.com')], - # # hashtags=[StoryHashtag(hashtag=get_hastags(address,title), x=0.23, y=0.32, width=0.5, height=0.22)], - # #medias=[StoryMedia(media_pk=media_pk, x=0.5, y=0.5, width=0.6, height=0.8)], - # ) - # story = instasession.story_photo("path/to/photo.jpg") - # instasession.video_elements.add_link("https://www.joeeatswhat.com") - # #story.add_link("https://www.joeeatswhat.com") - # instasession.video_elements.add_hashtags(get_hastags) - # story = instasession.video_upload_to_story(outputmontage) - # story.upload() - # #instasession.video_upload_to_story(path:outputmontage,caption:content, mentions:r'@timberjoe',links:'https://www.joeeatswhat.com',hashtags: hastag) ( path: outputmontage, caption: content, mentions:['@timberjoe'], links: ['https://www.joeeatswhat.com'], hashtags: get_hastags ) - # # temp = dict() - # # temp = instasession.video_upload_to_story(path=outputmontage,caption=content,mentions=r'@timberjoe',links='https://www.joeeatswhat.com',hashtags=get_hastags) - # except AttributeError as error: - # print(" An error occurred uploading video to Instagram:", type(error).__name__) # An error occurred: - # return False return True else: print (' Missing wordpress post for instagram : ',title) @@ -1188,7 +1156,7 @@ def post_to_wordpress(title,content,headers,date,rating,address,picslist,local_o None """ # post - newPost = False + new_post = False #countreview = False addresshtml = re.sub(" ", ".",address) googleadress = r"