-
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
3395d25
commit 32400fc
Showing
14 changed files
with
490 additions
and
272 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
keys.txt | ||
config.txt | ||
temp.json | ||
**/crossout/ | ||
**/__pycache__/ |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,51 @@ | ||
import sys | ||
import frontmatter | ||
from dev import devto | ||
from codenewbie import codenewbie | ||
from hashnode import hashnode | ||
import json | ||
|
||
def get_default_or_input(dictionary, keys): | ||
for key in keys: | ||
if key in dictionary.keys(): | ||
return dictionary[key] | ||
return input(f"Enter the {keys[0]} for post: ") | ||
file_markdown = sys.argv[1] | ||
|
||
post = frontmatter.load(file_markdown) | ||
|
||
with open("config.json", "r") as out: | ||
config = json.load(out) | ||
|
||
blog_link = config["blog_link"] | ||
|
||
article = {} | ||
article["title"] = get_default_or_input(post, ["title"]) | ||
article["description"] = get_default_or_input(post, ["subtitle", "description"]) | ||
slug = get_default_or_input(post, ["slug", "canonical_url"]) | ||
image_url = get_default_or_input(post, ["image_url"]) | ||
canonical_url = blog_link + str(slug) | ||
article["canonical_url"] = canonical_url | ||
article["cover_image"] = image_url | ||
article["tags"] = get_default_or_input(post, ["tags"]) | ||
# article['date']=post['date'] | ||
status = get_default_or_input(post, ["status", "published"]) | ||
if status == "published": | ||
article["published"] = "true" | ||
else: | ||
article["published"] = "false" | ||
article["body_markdown"] = post.content | ||
if "series" in post: | ||
article["series"] = post["series"] | ||
|
||
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": | ||
devto(article) | ||
elif opt == "2": | ||
hashnode(article) | ||
elif opt == "3": | ||
codenewbie(article) | ||
else: | ||
print("Invalid Option") |
File renamed without changes.
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,4 @@ | ||
{ | ||
"blog_link": "https://www.meetgor.com/", | ||
"output_folder": "crossout" | ||
} |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.