Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisAlejandro committed Aug 30, 2023
2 parents a07779f + 0e80a1c commit 64131f1
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 49 deletions.
9 changes: 0 additions & 9 deletions .bumpversion.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code Quality

on:
schedule:
- cron: '00 6 * * 2'
- cron: "00 6 * * 2"

jobs:
build:
Expand All @@ -11,10 +11,12 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python
config-file: ./.github/codeql-config.yml

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v2
7 changes: 5 additions & 2 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Functional tests

on:
workflow_dispatch:
schedule:
- cron: '00 6 * * 2'
- cron: "00 6 * * 2"

jobs:
functional:
Expand All @@ -13,17 +14,19 @@ jobs:
network:
- twitter
- facebook
- instagram
- linkedin
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/[email protected]
with:
python-version: 3.10

- name: Installing dependencies
run: |
sudo pip install -r requirements.txt -r requirements-dev.txt
- run: |
bash test.sh ${{ matrix.network }}
18 changes: 12 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,27 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Installing dependencies
run: |
sudo apt-get install libxml2-dev libxslt-dev
sudo pip install -r requirements.txt -r requirements-dev.txt
- name: Measuring coverage
env:
TOXENV: ${{ matrix.toxenv }}
PYTHON_VERSION: ${{ matrix.python-version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tox -e ${TOXENV}
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
Expand All @@ -54,11 +60,11 @@ jobs:
runs-on: ubuntu-22.04
needs: unit
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

approve:
name: Approve pull request
Expand All @@ -84,4 +90,4 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
})
})
14 changes: 9 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Installing dependencies
run: |
sudo apt-get install libxml2-dev libxslt-dev
sudo pip install -r requirements.txt -r requirements-dev.txt
- name: Measuring coverage
env:
TOXENV: ${{ matrix.toxenv }}
PYTHON_VERSION: ${{ matrix.python-version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tox -e ${TOXENV}
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
Expand All @@ -50,8 +54,8 @@ jobs:
runs-on: ubuntu-22.04
needs: build
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
11 changes: 11 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ Changelog
============


1.0.1 (2023-08-30)
------------

Other
~~~~~~~~~~~~

* `[REF]` Improving linkedin authentication. [Luis Alejandro Martínez Faneyth]

* `[REF]` Fixing test. [Luis Alejandro Martínez Faneyth]


1.0.0 (2023-08-29)
------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ servedocs: docs start
@$(exec_on_docker) watchmedo shell-command -p '*.rst' -c 'make -C docs html' -R -D .

release: clean start dist
@$(exec_on_docker) twine upload -s -i [email protected] dist/*
@$(exec_on_docker) twine upload dist/*

dist: clean start
@$(exec_on_docker) python3 -m build
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
.. _GitHub actions: https://github.com/LuisAlejandro/agoras-actions
.. _full documentation: https://agoras.readthedocs.org

Current version: 1.0.0
Current version: 1.0.1

Agoras is a python utility that helps publish and delete posts on the most
popular social networks (twitter, facebook, instagram and linkedin).
Expand Down
6 changes: 3 additions & 3 deletions README.short.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
.. _GitHub actions: https://github.com/LuisAlejandro/agoras-actions
.. _full documentation: https://agoras.readthedocs.org

Current version: 0.1.0
Current version: 1.0.1

Agoras is a python utility that helps publish and delete posts on the most
popular social networks (twitter, facebook, instagram and linkedin).

This repository stores the application. There's also `GitHub actions`_ that you can
incorporate into your workflows.
This repository stores the application. There's also `GitHub actions`_
that you can incorporate into your workflows.

For more information, please read the `full documentation`_.
2 changes: 1 addition & 1 deletion agoras/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

__author__ = 'Luis Alejandro Martínez Faneyth'
__email__ = '[email protected]'
__version__ = '1.0.0'
__version__ = '1.0.1'
__url__ = 'https://github.com/LuisAlejandro/agoras'
__description__ = ('A command line python utility to manage your social'
' networks (Twitter, Facebook, LinkedIn and Instagram)')
2 changes: 1 addition & 1 deletion agoras/core/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def schedule(client, facebook_object_id, google_sheets_id,
worksheet.clear()

for row in newcontent:
worksheet.append_row(row)
worksheet.append_row(row, table_range='A1')


def main(kwargs):
Expand Down
2 changes: 1 addition & 1 deletion agoras/core/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def schedule(client, instagram_object_id, google_sheets_id,
worksheet.clear()

for row in newcontent:
worksheet.append_row(row)
worksheet.append_row(row, table_range='A1')


def main(kwargs):
Expand Down
52 changes: 49 additions & 3 deletions agoras/core/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,37 @@
import tempfile
import time
from html import unescape
from typing import cast
from urllib.parse import quote
from urllib.request import Request, urlopen

import filetype
import gspread
import requests
from atoma import parse_rss_bytes
from bs4 import BeautifulSoup
from bs4.element import Tag
from dateutil import parser
from google.oauth2.service_account import Credentials
from linkedin_api import Linkedin
from linkedin_api.client import ChallengeException

from agoras import __version__
from agoras.core.utils import add_url_timestamp

api_url_host = 'https://www.linkedin.com/voyager'

ui_url_host = 'https://www.linkedin.com'
api_url_host = f'{ui_url_host}/voyager'

ui_login_endpoint = (
f'{ui_url_host}'
'/checkpoint/lg/login-submit'
)
ui_seed_endpoint = (
f'{ui_url_host}'
'/uas/login'
)

media_upload_endpoint = (
f'{api_url_host}'
'/api/voyagerVideoDashMediaUploadMetadata?action=upload')
Expand Down Expand Up @@ -334,7 +351,24 @@ def schedule(client, google_sheets_id,
worksheet.clear()

for row in newcontent:
worksheet.append_row(row)
worksheet.append_row(row, table_range='A1')


def prime_linkedin_login(linkedin_username, linkedin_password):

session = requests.Session()

login_session = session.get(ui_seed_endpoint)
soup = BeautifulSoup(login_session.text, 'html.parser')
csrf = cast(Tag, soup.find('input', {'name': 'loginCsrfParam'}))

payload = {
'session_key': linkedin_username,
'session_password': linkedin_password,
'loginCsrfParam': csrf.get('value')
}

session.post(ui_login_endpoint, data=payload)


def main(kwargs):
Expand Down Expand Up @@ -384,7 +418,19 @@ def main(kwargs):
google_sheets_private_key.replace('\\n', '\n') \
if google_sheets_private_key else ''

client = Linkedin(linkedin_username, linkedin_password)
try:
client = Linkedin(linkedin_username, linkedin_password)
except ChallengeException:
try:
prime_linkedin_login(linkedin_username, linkedin_password)
except Exception:
pass
try:
client = Linkedin(linkedin_username, linkedin_password)
except ChallengeException:
raise Exception('LinkedIn ChallengeException: '
'This is a known issue. Please login to '
'your LinkedIn account and try again.')

if action == 'post':
post(client, status_text,
Expand Down
2 changes: 1 addition & 1 deletion agoras/core/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def schedule(client, clientv1, google_sheets_id, google_sheets_name,
worksheet.clear()

for row in newcontent:
worksheet.append_row(row)
worksheet.append_row(row, table_range='A1')


def main(kwargs):
Expand Down
2 changes: 1 addition & 1 deletion docs/instagram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Then click on submit and you'll see a response like this::

"ZZZZZZZ" is your Instagram aacount ID.

.. image:: images/instagram-2.png
.. image:: credentials/images/instagram-2.png

How to get google spreadsheets credentials
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ google-auth==2.22.0
linkedin-api==2.0.1
python-dateutil==2.8.2
filetype==1.2.0
requests==2.31.0
beautifulsoup4==4.8.2
15 changes: 8 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
[bumpversion]
current_version = 0.1.0
current_version = 1.0.1
tag_name = {new_version}
commit = True
tag = True

[bumpversion:file:README.rst]

[bumpversion:file:README.short.rst]

[bumpversion:file:agoras/__init__.py]

[flake8]
max-line-length = 120
max-complexity = 12
max-complexity = 15
doctests = True

[bdist_wheel]
universal = 1

[bumpversion:file:README.rst]

[bumpversion:file:agoras/__init__.py]

Loading

0 comments on commit 64131f1

Please sign in to comment.