Esempio n. 1
0
def get_history(channel_id):
    gist = Simplegist(username='******',
                      api_token=os.environ["GIST_ACCESS_TOKEN"])
    sectioned_links = get_links(get_messages(channel_id))
    json_file = gist.create(name=get_channel_name(channel_id) + ".json",
                            description="json for channel links",
                            content=json.dumps(original_json(sectioned_links)))
    md_file = gist.create(name=get_channel_name(channel_id) + ".md",
                          description="Collected links of channel",
                          content=generate_md_file(sectioned_links,
                                                   channel_id))
    keys = json.loads(gist.profile().content(id=gist_list_id))
    keys[channel_id] = [json_file['id'], md_file['id']]
    gist.profile().edit(id=gist_list_id, content=json.dumps(keys))
    return md_file['Gist-Link']
Esempio n. 2
0
class MyGist:
    def __init__(self, name, description, content, username="", api_token=""):
        self.name = name
        self.description = description
        self.content = content
        self.gist_connection = Simplegist(username=username,
                                          api_token=api_token)
        gist_info = self.gist_connection.create(name=self.name,
                                                description=self.description,
                                                public=True,
                                                content=self.content)
        self.gist_link = gist_info["Gist-Link"]
        self.url = self.gist_link
        self.clone_link = gist_info["Clone-Link"]
        self.embed_script = gist_info["Embed-Script"]
        self.id = gist_info["id"]
        self.created_at = gist_info['created_at']

    def update(self, name=None, description=None, content=None):
        if name is not None:
            self.name = name
        if description is not None:
            self.description = description
        if content is not None:
            self.content = content
        self.gist_connection.profile().edit(id=self.id,
                                            description=self.description,
                                            name=self.name,
                                            content=self.content)
Esempio n. 3
0
def get_history(channel_id):
    gist = Simplegist(username='******',
                      api_token=os.environ["GIST_ACCESS_TOKEN"])
    total_links = merge_dicts(get_all_links(channel_id))
    json_data = {
        category: [link.to_json() for link in links]
        for category, links in total_links.items()
    }
    # updates the json
    json_file = gist.create(name=get_channel_name(channel_id) + ".json",
                            description="json for channel links",
                            content=json.dumps(json_data))
    md_file = gist.create(name=get_channel_name(channel_id) + ".md",
                          description="Collected links of channel",
                          content=generate_md_file(total_links, channel_id))
    keys = json.loads(gist.profile().content(id=gist_list_id))
    keys[channel_id] = [json_file['id'], md_file['id']]
    gist.profile().edit(id=gist_list_id, content=json.dumps(keys))
    generate_findall()
    return md_file['Gist-Link']