def spin_video_detail():
    print('indexing shortcodes ....')
    shortcodes = os.listdir('./shortcodes')
    print('reading video description ....')
    f = open('input.txt', 'r')
    title = f.readline()
    title = title.replace('\n', '')
    description = f.readline()
    keywords = f.readline()
    print('replacing shortcode ....')
    for shortcode in shortcodes:
        f = open('shortcodes/' + shortcode, 'r')
        text = f.readline()
        shortcode = '[' + shortcode.replace(
            '.txt',
            '',
        ) + ']'
        if shortcode in title:
            title = title.replace(shortcode, text)
        if shortcode in description:
            description = description.replace(shortcode, text)
        if shortcode in keywords:
            keywords = keywords.replace(shortcode, text)
    print('spinning video detail ....')
    title = spintax.spin(title)
    if '[title]' in description:
        description = description.replace('[title]', title)
    if '[title]' in keywords:
        keywords = keywords.replace('[title]', title)
    keywords = spintax.spin(keywords)
    tags = keywords.split(',')
    description = description.replace('\\n', '\n')
    description = spintax.spin(description)
    return dict(title=title, desc=description, tags=tags)
Example #2
0
 def on_data(data: json) -> None:
     if "direct_message_events" in data:
         message = data["direct_message_events"][0]["message_create"]
         sender_id = message["sender_id"]
         if int(sender_id) == me.id:
             return
         reply_text = responders.process_fess(message)
         responders.api.send_direct_message(sender_id,
                                            spintax.spin(reply_text))
Example #3
0
 def main(self):
     while True:
         new_dms = self.get_new_dms()
         for new_dm in new_dms:
             recipient_id = new_dm["sender_id"]
             reply_text = self.process_fess(new_dm)
             self.api.send_direct_message(recipient_id, spintax.spin(reply_text))
             time.sleep(15)
         time.sleep(60)
Example #4
0
def spin(string, repeat):
    text_spinned = []

    for i in range(repeat):
        spin = (spintax.spin(string))
        text_spinned.append(spin)

    df = pd.DataFrame({"text": text_spinned})

    df.to_csv("spinned_texts.csv")
Example #5
0
def get_message(msg_path, **kwargs):
    """
    get and format message from template
    :param msg_path: name of the message
    :return: text
    """
    global data

    path = msg_path.split("/")
    dirc = data
    for key in path:
        dirc = dirc[key]

    template = Template(dirc)
    text = template.substitute(**kwargs)
    return spintax.spin(text)
Example #6
0
 def test_escaped_at_end_only_one(self):
     set_up = set([spintax.spin(r"{a\\}") for a in range(50)])
     self.assertEqual(set_up, {'a\\'})
Example #7
0
 def test_escaped_pipe_at_end(self):
     set_up = set([spintax.spin("{a\||b\|}") for a in range(50)])
     self.assertEqual(set_up, {'b|', 'a|'})
Example #8
0
    print(regex)
    return '.' + (regex[0].split('\"')[1]).replace(' ', '.')


def findclassnameafter(name, inputdata):
    regex = re.findall(name + r'class=".{,50}"', inputdata)
    return '.' + (regex[0].split('\"'))[3].replace(' ', '.')




for path, subdirs, files in os.walk('./Articles/'):
    for name in files:
        print(os.path.join(path, name))
        with open(os.path.join(path, name), 'r', encoding='utf-8') as openedfile:
            article = spintax.spin(openedfile.read())
        openedfile.close()
        try:
            os.remove(os.path.join(path, name))
        except OSError:
            pass

        with open('counterfile.txt', 'r') as counterfile:
            counter = counterfile.read()
        counter = int(counter)

        print(type(counter))
        print(article)

        print(re.findall('(?<=#title#).*(?=#title#)', article))
        print(re.findall('(?<=#body#).*(?=#body#)', article))
Example #9
0
# running bot------------------------------------------------------------------------------------
if __name__ == '__main__':
    email = config.email
    password = config.password

    driver = youtube_login(email, password)

    while True:
        key = driver.find_element_by_name('search_query')

        # get keyword list and extract each key
        with open('keywords.txt', 'r') as f:
            keywords = [line.strip() for line in f]
            random_keyword = random.choice(keywords)
            keys = spintax.spin(random_keyword)

            # send keyword in the search box
            for char in keys:
                key.send_keys(char)

        time.sleep(1)

        # click search icon
        driver.find_element_by_css_selector(
            '#search-icon-legacy > yt-icon').click()
        time.sleep(3)
        # click filter button to filter the videos for the recently uploaded, you can remove or edit this option
        driver.find_element_by_css_selector(
            '#container > ytd-toggle-button-renderer > a').click()
        time.sleep(3)
Example #10
0
def GenerateSuperHeroName():
    SuperHeroName = spintax.spin(r"{The|One|A|}{Big|Large|Small|Tiny|Giant|Titanic|Massive}{Blue|Red|Green|Yellow|Purple|Violet|Rose|Black|White|Pink}{Dog|Cat|Pig|Cow|Chicken|Rabbit|Sheep|Duck|Goat|Elephant}{Is|IsNow|HasBeen|Was|WasJust|}{Happily|Gladly|Joyfully|}{Eating|Jumping|Running|Walking|Smiling|Playing|Laughing}")
    return SuperHeroName
Example #11
0
 def test_not_escaped_seperator(self):
     self.assertIn(spintax.spin(r'{Hello\\|Hi}'), ['Hello\\', 'Hi'])
Example #12
0
 def get_random_reply(self):
     """Get a random reply to this message, based on its contents."""
     # Right now it's not very much based on the original email's contents.
     reply = ReplyTemplate.objects.filter(
         category=self.conversation.category).order_by("?").first()
     return spintax.spin(reply.body)
Example #13
0
 def test_nested(self):
     self.assertIn(spintax.spin('{{Hello|Hi}|{Hey|Yo}}'),
                   ['Hello', 'Hi', 'Hey', 'Yo'])
Example #14
0
 def test_nothing(self):
     self.assertEqual(spintax.spin('nothing'), 'nothing')
Example #15
0
 def test_simple(self):
     self.assertIn(spintax.spin('{Hello|Hi}'), ['Hello', 'Hi'])
Example #16
0
def spin(txt):
    rez = spintax.spin(txt)
    printX("Text spintax result:" + rez)
    return rez
def GenerateSuperHeroName():
    SuperHeroName = spintax.spin(r"{The |}{Super|Scarlet|Commander|Hydro|Captain|Fantastic|Colossal|Nighthawk|Wild} {Mountain|Hawk|Flame|Claw|Machine|Watchman}")
    return SuperHeroName
Example #18
0
 def get_link(self):
     text = quote(spintax.spin("Send me anonymous messages {🤫|😋} #tellly"))
     return self.url.substitute(link=self.link, text=text)
Example #19
0
    def enter_and_submit_phone_numbers_data(cls, phone_numbers):
        """ Enter data in text fields appearing on form and submit data."""
        list_chunk_range = 0
        while list_chunk_range < len(phone_numbers):
            slicing_range = random.randint(6, 10)

            chrome_options = Options()
            chrome_options.add_argument("--disable-extensions")
            chrome_options.add_argument("--disable-gpu")
            chrome_options.add_argument("--headless")
            chrome_options.add_argument("--log-level=3")
            cls.driver = webdriver.Chrome(executable_path=driver_path,
                                          options=chrome_options)
            cls.driver.get(PAGE_URL)

            numbers = []
            for phone_number_key in phone_numbers[
                    list_chunk_range:list_chunk_range + slicing_range]:
                numbers.append(phone_number_key['phone_number'])

            phone_number_string = ','.join(numbers)
            if len(numbers) == slicing_range:
                print(
                    f"\n************* Chunk of {slicing_range} Phone numbers are:  *************\n"
                    f"{phone_number_string}\n")
            else:
                print(
                    f"\n************* Chunk of remaining Phone number(s) are:  *************\n"
                    f"{phone_number_string}\n")

            WebDriverWait(cls.driver, ELEMENT_WAIT_TIME).until(
                EC.visibility_of_element_located(
                    (By.CSS_SELECTOR, '[type="submit"]')))
            send_to_field = cls.driver.find_element_by_css_selector(
                '#id_Send_to')
            send_to_field.clear()
            message_field = cls.driver.find_element_by_css_selector(
                '#id_Message')
            message_field.clear()

            send_to_field.send_keys(phone_number_string)
            message_field.send_keys(spintax.spin(message_text))

            resp_id = cls.solve_captcha()
            cls.captcha_response_token = cls.get_captcha_token(resp_id=resp_id)
            while cls.captcha_response_token == '' and cls.retrieve_captcha_attempt < 5:
                cls.captcha_response_token = cls.get_captcha_token(
                    resp_id=resp_id)
                cls.retrieve_captcha_attempt = cls.retrieve_captcha_attempt + 1

            if cls.captcha_response_token:
                cls.driver.execute_script(
                    "document.getElementById('g-recaptcha-response').style.removeProperty('display');"
                )
                captcha_response_field = cls.driver.find_element_by_css_selector(
                    '#g-recaptcha-response')
                captcha_response_field.clear()
                captcha_response_field.send_keys(cls.captcha_response_token)
            else:
                print(
                    "Did not get Captcha solved response from 2Captcha Server so leaving this chunks of Phone Numbers"
                )

            submit_button = cls.driver.find_element_by_css_selector(
                '[type="submit"]')
            submit_button.click()
            time.sleep(2)

            try:
                cls.captcha_response_token = ''
                cls.retrieve_captcha_attempt = 0

                WebDriverWait(cls.driver, ELEMENT_WAIT_TIME).until(
                    EC.visibility_of_element_located(
                        (By.CSS_SELECTOR, '.messages .success')))

                message_sent_status = cls.driver.find_element_by_css_selector(
                    '.messages .success').text

                if "message(s) successfully sent" in message_sent_status:
                    for phone_number_key in numbers:
                        success.append(phone_number_key)
                    print("Message sent successfully to these phone numbers: ",
                          phone_number_string)

            except:
                incorrect_numbers = []
                error_contains_phone_number = False

                WebDriverWait(cls.driver, ELEMENT_WAIT_TIME).until(
                    EC.visibility_of_element_located(
                        (By.CSS_SELECTOR, '.messages li')))
                message_failure_status = cls.driver.find_elements_by_css_selector(
                    '.messages li')

                for error_key in message_failure_status:
                    error_contains_phone_number = any(
                        char.isdigit() for char in error_key.text)

                    if error_contains_phone_number:
                        error_text = error_key.text.split()
                        incorrect_numbers.append(error_text[0])
                        errors.append(error_text[0])

                if not error_contains_phone_number:
                    for num_key in numbers:
                        errors.append(num_key)

                if error_contains_phone_number and len(
                        incorrect_numbers) != len(numbers):
                    for num_key in numbers:
                        if num_key not in incorrect_numbers:
                            success.append(num_key)

                if error_contains_phone_number:
                    print("messages sending failed to these phone numbers: ",
                          ",".join(incorrect_numbers))
                else:
                    print("messages sending failed to these phone numbers: ",
                          ",".join(numbers))

            cls.driver.quit()
            list_chunk_range = list_chunk_range + slicing_range

        if success:
            return {"success": success}
        elif errors:
            return {"errors": errors}
Example #20
0
 def test_escaped_with_backslash(self):
     self.assertEqual(spintax.spin(r'\\\{test}'), r'\{test}')
Example #21
0
 def test_nested(self):
     self.assertIn(spintax.spin('{{Hello|Hi}|{Hey|Yo}}'),
                   ['Hello', 'Hi', 'Hey', 'Yo'])
    def createpost(self, listing):
        if not self.isLoggedIn:
            self.debug("ERROR: You're not logged in!")
            return 0

        #self.debug("Attempting to post this listing:")
        #self.debug(listing.tostring() + "\n")

        #self.debug("Navigating to post page")

        #self.debug("locationCode: " + self.locationCode)
        initialPostUrl = "https://post.craigslist.org/c/" + self.locationCode
        #self.debug("navigating to " + initialPostUrl)
        self.client.get(initialPostUrl)

        self.waitForCss("input[value='1']")

        self.client.find_element_by_css_selector("input[value='1']").click()

        # fso = for sale by owner
        # so  = service offered
        self.client.find_element_by_css_selector("input[value='fso']").click()
        time.sleep(self.waitTime)

        # 199 = computer parts
        # 7   = computers
        # 96  = electronics
        self.client.find_element_by_css_selector("input[value='96']").click()
        time.sleep(self.waitTime)
        """
        self.debug("Trying to fill in email")
        try:
            self.client.find_element_by_css_selector(
                '#FromEMail').send_keys(self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")
        try:
            self.client.find_element_by_css_selector(
                '#FromEMail').send_keys(self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")
        """

        #self.debug("Checking 'Okay to contact by phone'")
        self.waitForName("show_phone_ok")
        self.client.find_element_by_name("show_phone_ok").click()
        self.client.find_element_by_name("contact_phone_ok").click()

        #self.debug("Checking 'Okay to contact by text'")
        self.client.find_element_by_name("contact_text_ok").click()

        #self.debug("Filling in contact phone number")
        self.client.find_element_by_name("contact_phone").send_keys(
            self.contactNumber)

        #self.debug("Filling in contact name")
        self.client.find_element_by_name("contact_name").send_keys(
            self.contactName)

        #self.debug("Filling in post title")
        spinName = spintax.spin(listing.name)
        self.client.find_element_by_name("PostingTitle").send_keys(spinName)

        #self.debug("Filling in zip code")
        self.client.find_element_by_id("postal_code").send_keys(self.postCode)

        #self.debug("Filling in post content")
        spinDescription = spintax.spin(listing.description)
        self.client.find_element_by_name("PostingBody").send_keys(
            spinDescription)

        #self.debug("Checking 'Okay to contact for other offers'")
        self.waitForName("contact_ok")
        self.client.find_element_by_name("contact_ok").click()

        # self.debug("Unchecking 'Want a map' if checked")
        # try:
        #    self.client.find_element_by_css_selector("#wantamap:checked")
        # except NoSuchElementException:
        #    self.debug("Not checked")
        # finally:
        #    self.client.find_element_by_css_selector("#wantamap:checked").click()
        # time.sleep(self.waitTime)

        #self.debug("Clicking continue")
        self.client.find_element_by_name("go").click()

        # if "editimage" in self.client.current_url:  # FIX tHIS
        #   self.debug("Clicking continue")
        #   self.client.find_element_by_css_selector('button.done').click()
        # else:
        #   self.debug(
        #      "Could not submit. Maybe a bad email address or phone number")

        #self.debug("Clicking publish")
        self.waitForClass("bigbutton")
        self.client.find_element_by_class_name('bigbutton').click()

        # determine if we need to switch to classic uploading
        time.sleep(self.waitTime)
        if len(self.client.find_elements_by_id('classic')) != 0:
            #self.debug("clicking use classic image uploader")
            self.waitForId("classic")
            time.sleep(self.waitTime)
            self.client.find_element_by_id('classic').click()
            time.sleep(self.waitTime
                       )  # must wait for classic to pop into the viewport

        #self.debug("uploading images")
        self.waitForName("file")
        for imagePath in listing.imagePathList:
            self.debug("Attempting to upload image: " + os.getcwd() + "/" +
                       imagePath)
            self.client.find_element_by_name("file").send_keys(os.getcwd() +
                                                               "/" + imagePath)
            time.sleep(self.waitTime)

        self.debug("Clicking done with images")
        self.waitForClass("bigbutton")
        self.client.find_element_by_class_name('bigbutton').click()

        self.debug("Click publish (again)")
        self.waitForName("go")
        self.client.find_element_by_name('go').click()

        # check if we need to verify the post
        self.debug("Check if the post needs verified")
        time.sleep(self.waitTime)
        htmlText = self.client.find_element_by_css_selector("body").text
        # self.debug(htmlText)
        if "FURTHER ACTION REQUIRED" in htmlText:
            # wait for the email to come through and then verify it
            self.debug("must verify post")
            time.sleep(45)
            self.validatePostInEmail()

        return self.client.find_element_by_css_selector(
            "ul.ul").find_elements_by_css_selector("a")[0].get_attribute(
                "href")
Example #23
0
 def test_simple(self):
     self.assertIn(spintax.spin('{Hello|Hi}'), ['Hello', 'Hi'])
Example #24
0
 def test_not_escaped(self):
     self.assertEqual(spintax.spin(r'\\{test}'), r'\test')
Example #25
0
 def test_not_escaped(self):
     self.assertEqual(spintax.spin(r'\\{test}'), r'\test')
Example #26
0
 def test_escaped_with_backslash(self):
     self.assertEqual(spintax.spin(r'\\\{test}'), r'\{test}')
Example #27
0
 def test_escaped_seperator(self):
     self.assertEqual(spintax.spin('{Hello\|Hi}'), r'Hello|Hi')
Example #28
0
 def test_escaped_seperator(self):
     self.assertEqual(spintax.spin('{Hello\|Hi}'), r'Hello|Hi')
Example #29
0
 def test_escaped_seperator_with_backslash(self):
     self.assertEqual(spintax.spin(r'{Hello\\\|Hi}'), r'Hello\|Hi')
Example #30
0
 def test_not_escaped_seperator(self):
     self.assertIn(spintax.spin(r'{Hello\\|Hi}'), ['Hello\\', 'Hi'])
Example #31
0
 def test_escaped_seperator_with_backslash(self):
     self.assertEqual(spintax.spin(r'{Hello\\\|Hi}'), r'Hello\|Hi')
Example #32
0
 def test_newline(self):
     set_up = set([spintax.spin("{a\n|b\n}") for a in range(50)])
     self.assertEqual(set_up, {'b\n', 'a\n'})
Example #33
0
import spintax
import super_hero_name_generator

# Generate Super hero name
SuperHeroName = super_hero_name_generator.GenerateSuperHeroName()

# Generate greeting
SuperHeroText = r"""
{Hello|Hi|Hey}{,|} I{'| a}m \{0\}{,|!|!!!}
I {{come|am} {here|on this earth}|{came|travelled} {here|to this place}} to {protect|save} {humanity|the world|humans|civilization} {and {destroy|kill|eradicate|remove}|by {destroy|kill|eradicat|remov}ing} all {evil|badness|hate}.
"""
# As the { and } were escaped this allowed us to use .format() to insert the name
print(spintax.spin(SuperHeroText).format(SuperHeroName))
def GenerateSuperHeroName():
    SuperHeroName = spintax.spin(
        r"{The |}{Super|Scarlet|Commander|Hydro|Captain|Fantastic|Colossal|Nighthawk|Wild} {Mountain|Hawk|Flame|Claw|Machine|Watchman}"
    )
    return SuperHeroName