-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a7a7bf
commit 71ea64e
Showing
6 changed files
with
127 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import sys | ||
import frontmatter | ||
import dev | ||
import codenewbie | ||
|
||
file_markdown = sys.argv[1] | ||
|
||
with open(file_markdown,'r') as file: | ||
article = file.read() | ||
|
||
post=frontmatter.load(file_markdown) | ||
|
||
title=post['title'] | ||
subtitle=post['subtitle'] | ||
canonical_url=post['canonical_url'] | ||
cover_image=post['cover_image'] | ||
tags=post['tags'] | ||
date=post['date'] | ||
publishe=post['published'] | ||
article=post.content | ||
|
||
print(f"1. dev.to \n2. hashnode.com\n3. codenewbie\n4. medium.com\n") | ||
opt = input("Where you would like to post? (1/2/3/4) : ") | ||
|
||
if(opt == '1'): | ||
dev.devto(article) | ||
elif(opt == '3'): | ||
codenewbie.codenewbie(article) | ||
else: | ||
print("Invalid Option") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
import requests | ||
import sys | ||
|
||
markdown = sys.argv[1] | ||
with open(markdown,'r') as file: | ||
article = file.read() | ||
def codenewbie(article): | ||
|
||
with open('keys.txt', 'r') as file: | ||
keys = file.readlines() | ||
with open('keys.txt', 'r') as file: | ||
keys = file.readlines() | ||
|
||
codenewbie_keys = keys[5] | ||
codenewbie_keys = codenewbie_keys.split('codenewbie:')[1].strip() | ||
|
||
API_ENDPOINT = "https://community.codenewbie.org/api/articles" | ||
|
||
data = { | ||
'Content-Type': 'application/json', | ||
'article': {'body_markdown':article}, | ||
} | ||
|
||
response = requests.post(url = API_ENDPOINT,json=data, headers={"api-key":codenewbie_keys}).json() | ||
|
||
print("The article URL is:", response['url']) | ||
codenewbie_keys = keys[5] | ||
codenewbie_keys = codenewbie_keys.split('codenewbie:')[1].strip() | ||
|
||
API_ENDPOINT = "https://community.codenewbie.org/api/articles" | ||
|
||
data = { | ||
'Content-Type': 'application/json', | ||
'article': {'body_markdown':article}, | ||
} | ||
|
||
response = requests.post(url = API_ENDPOINT,json=data, headers={"api-key":codenewbie_keys}).json() | ||
|
||
print("The article URL is:", response['url']) | ||
|
||
if(response['url']): | ||
return True | ||
return False |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import requests | ||
import sys | ||
|
||
markdown = sys.argv[1] | ||
with open(markdown,'r') as file: | ||
article = file.read() | ||
def devto(article): | ||
with open('keys.txt', 'r') as file: | ||
keys = file.readlines() | ||
|
||
with open('keys.txt', 'r') as file: | ||
keys = file.readlines() | ||
|
||
dev_keys = keys[0] | ||
dev_keys = dev_keys.split('dev.to:')[1].strip() | ||
|
||
API_ENDPOINT = "https://dev.to/api/articles" | ||
|
||
data = { | ||
'Content-Type': 'application/json', | ||
'article': {'body_markdown':article}, | ||
} | ||
|
||
response = requests.post(url = API_ENDPOINT,json=data, headers={"api-key":dev_keys}).json() | ||
|
||
print("The article URL is: ",response['url']) | ||
dev_keys = keys[0] | ||
dev_keys = dev_keys.split('dev.to:')[1].strip() | ||
API_ENDPOINT = "https://dev.to/api/articles" | ||
data = { | ||
'Content-Type': 'application/json', | ||
'article': {'body_markdown':article}, | ||
} | ||
|
||
response = requests.post(url = API_ENDPOINT,json=data, headers={"api-key":dev_keys}).json() | ||
|
||
print("The article URL is: ",response['url']) | ||
if(response['url']): | ||
return True | ||
return False |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import requests | ||
import sys | ||
|
||
markdown = sys.argv[1] | ||
with open(markdown,'r') as file: | ||
article = file.read() | ||
|
||
with open('keys.txt', 'r') as file: | ||
keys = file.readlines() | ||
|
||
hashnode_keys = keys[4] | ||
hashnode_keys = hashnode_keys.split('hashnode:')[1].strip() | ||
|
||
API_ENDPOINT = "https://api.hashnode.com" | ||
|
||
# Work in progress | ||
#data= '{"query":"mutation { | ||
# createPublicationStory( | ||
# input: { | ||
# title: \"'"$title"'\", | ||
# contentMarkdown: \"'"$body"'\" | ||
# tags: [ | ||
# { | ||
# _id: \"56744721958ef13879b94ffc\", | ||
# name: \"General Programming\", | ||
# slug: \"programming\" | ||
# } | ||
# ] | ||
# coverImageURL:\"'"$cover_image"'\" } | ||
# publicationId:\"'"$hash_id"'\", | ||
# hideFromHashnodeFeed:false | ||
# ) { | ||
# message | ||
# post{ | ||
# title | ||
# coverImage | ||
# } | ||
# } | ||
# } | ||
# }' --compressed | ||
# | ||
#header = { | ||
# 'Accept-Encoding': 'gzip, deflate', | ||
# 'Content-Type': 'application/json', | ||
# 'Accept': 'application/json', | ||
# 'Connection': 'keep-alive', | ||
# 'DNT': '1' | ||
# 'Origin': 'https://api.hashnode.com' | ||
# 'Authorization': hashnode_keys, | ||
# } | ||
# | ||
#response = requests.post(url = API_ENDPOINT,json=data, headers=header.json()) | ||
# | ||
#print("The article URL is:", response['url']) | ||
|