Esempio n. 1
0
    def process_item(self, item, spider):
        comic = Comic()
        comic.comic_strip = self.comic_strip
        comic.date = item['date']
        if 'title' in item:
            comic.title = item['title']
        else:
            comic.title = None

        if comic.title is None:
            comic.title = "{} : {}/{}/{}".format(self.comic_strip.name,
                                                 comic.date.month,
                                                 comic.date.day,
                                                 comic.date.year)

        comic.comic_page_url = item['comic_page_url']
        comic.comic_url = item['comic_url']
        if 'alt_text' in item:
            comic.alt_text = item['alt_text']
        if 'alt_comic_url' in item:
            comic.alt_comic_url = item['alt_comic_url']
        try:
            comic.save()
        except IntegrityError:
            # Not needed, but we should try updating here.
            pass

        return item
Esempio n. 2
0
def createComic(user, title, panel1Id, panel2Id, panel3Id, panel4Id, panel5Id,
                panel6Id):
    try:
        comic = Comic.objects.get(panel1=panel1Id,
                                  panel2=panel2Id,
                                  panel3=panel3Id,
                                  panel4=panel4Id,
                                  panel5=panel5Id,
                                  panel6=panel6Id)
        return {'comicExisted': True, 'comic': comic}
    except Comic.DoesNotExist:
        if not verifyComicPanelIds(
            [panel1Id, panel2Id, panel3Id, panel4Id, panel5Id, panel6Id]):
            return None

        comic = Comic(panel1=panel1Id,
                      panel2=panel2Id,
                      panel3=panel3Id,
                      panel4=panel4Id,
                      panel5=panel5Id,
                      panel6=panel6Id,
                      title=title,
                      createdby=user,
                      datecreated=datetime.datetime.now())
        comic.save()
        return {'comicExisted': False, 'comic': comic}
Esempio n. 3
0
def createComic(user, title, panel1Id, panel2Id, panel3Id, panel4Id, panel5Id, panel6Id):
    try:
        comic = Comic.objects.get(panel1=panel1Id, panel2=panel2Id, panel3=panel3Id, panel4=panel4Id, panel5=panel5Id, panel6=panel6Id)
        return { 'comicExisted' : True, 'comic' : comic }
    except Comic.DoesNotExist:
        if not verifyComicPanelIds([panel1Id, panel2Id, panel3Id, panel4Id, panel5Id, panel6Id]):            
            return None
               
        comic = Comic(panel1=panel1Id, panel2=panel2Id, panel3=panel3Id, panel4=panel4Id, panel5=panel5Id, panel6=panel6Id, title=title, createdby=user, datecreated=datetime.datetime.now())
        comic.save()
        return { 'comicExisted' : False, 'comic' : comic }
Esempio n. 4
0
def create_comic():
    fake = Faker()

    comic = Comic(
        # the random values are imported from data.py
        name=random.choice(data.names),
        publisher=random.choice(data.publishers),
        description=fake.paragraph(nb_sentences=10, variable_nb_sentences=True),
        cover=random.choice(data.covers),
        price=random.uniform(0, 99)
    )

    comic.save()
Esempio n. 5
0
def random_comic(posted):
    words = random_name.special_thing()

    c = Comic(title=words,
              image_url="http://curtis.lassam.net/comics/cube_drone/{}.gif".format(random.choice(range(0, 140))),
              promo_text= "Promo text for {}".format(words)[:79],
              posted=posted,
              secret_text = "Secret text for {}".format(words),
              alt_text = "Alt text for {}".format(words),
              tags = [random_name.thing(), random_name.adjective(), random_name.noun()])
    if random.choice([False, False, False, True]):
        c.title = "Hidden {}".format(c.title)
        c.hidden = True
    c.save()
    print("Creating {}".format(c))
    return c
Esempio n. 6
0
def create_comic(item, posted, comic_url):
    secrettext = ""
    if 'secret-text' in item:
        secrettext = item['secret-text']
    alttext = ""
    if 'alt-text' in item:
        alttext = item['alt-text']

    tags = []
    for category in item['categories']:
        tags.append(slugify(category))

    if 'cube-drone' in tags:
        tags.remove('cube-drone')

    if '-' in item['title']:
        things = [thing.strip(" ") for thing in item['title'].split("-")]
        if "Interlude" in things or "interlude" in things:
            tags.append('interlude')
            things = things[1:]
        try:
            int(things[0])
            things = things[1:]
        except ValueError:
            pass
        item['title'] = " ".join(things)

    c = Comic(title=item['title'],
              posted=posted,
              image_url=comic_url,
              secret_text=secrettext,
              alt_text=alttext,
              promo_text="",
              hidden=not item['visible'],
              published=True,
              tags=tags)
    c.save()
    print("Created {}".format(c))