
    Mg                     l    S SK r S SKJr  S SKrS SKJrJr  \" SS9\" S5       " S S5      5       5       rg)	    N)BeautifulSoup)pluginrequireT)networkquotec                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
Quote   zK
quote prints quote for the day for you or quotes based on a given keyword
c                     SnU R                  X15      nUS:X  a  U R                  U5        g SnUR                  U5      nU R                  X5        g )NzMPress 1 to get the quote of the day 
 or 2 to get quotes based on a keyword:    z9Enter the keyword based on which you want to see quotes: )	get_inputget_quote_of_the_dayinputget_keyword_quotes)selfjarvissprompt
user_inputtextkeywords          ;/Users/admin/workspace/ai/Jarvis/jarviscli/plugins/quote.py__call__Quote.__call__   sK    a^^F3
?%%f-NDll4(G##F4    c                     [         R                  " S5      nUR                  S:X  aB  UR                  n[        R
                  " U5      nUS   S   S   S   nUR                  U5        g UR                  S5        g )Nzhttps://quotes.rest/qod   contentsquotesr   r   zXSorry, something went wrong. Please try again later or report this issue if it sustains.)requestsgetstatus_coder   jsonloadssay)r   r   resdata
parse_jsonr   s         r   r   Quote.get_quote_of_the_day   sh    ll%'??c!88DD)Jz*84Q7@EJJuJJqrr   c                 \    [         R                  " SU 35      n[        UR                  S5      nUR	                  SSS05      n/ nU H2  nUR                  SSS05      R                  nUR                  U5        M4     [        U5      n	S	n
U	S	:X  a.  UR                  S
U S35      nUR                  5       S:X  a  gUnM  U	S	:  ag  X:  a  S	n
Xj   nUR                  U5        UR                  S5      nUR                  5       S:X  a  U
S-   U	-  n
UR                  5       S:X  a   gU	S	:  a  Mg  g)z3
shows quotes based on a keyword given by the user
z5https://www.brainyquote.com/search_results?x=0&y=0&q=zhtml.parserdivclassbqQtatitlez
view quoter   z Sorry, no quotes were found for z6. Type a new keyword to try again or "exit" to leave: exitz3Type "again" for another quote or "exit" to leave: againr   N)r    r!   r   r   find_allfindappendlenr   lowerr%   )r   r   r   r&   soup
quote_divsr   	quote_div
quote_text
num_quotescurrent_quoteresponser   s                r   r   Quote.get_keyword_quotes%   s=   
 ,,!VW^V_`aC =9Duw.?@JF'	&^^C'<1HINN
j) ( VJMQ!<<6wi?uvx>>#v-"q. .$%M-

5!!<<(]^>>#w.%2Q%6*$DM>>#v- q. r   c                 b    SUR                  5       -   U;   =(       d    UR                  5       U;   $ )N )r6   
capitalize)r   r   r   s      r   contains_wordQuote.contains_wordO   s+    gmmo%!+J0B0B0D/JJr   c                       [        UR                  U5      5      nUR                  S5        US:w  a  US:w  a  UR                  S5        ML   U$ ! [         a    UR                  S5         Mm  f = f)z;
checks if the input the user gave is valid(either 1 or 2)
 z!
Sorry, I didn't understand that.r      z#
Sorry, your response is not valid.)intr   r%   
ValueError)r   r   r   r=   s       r   r   Quote.get_inputR   sr    
 v||F34

2
 AHM

AB  

?@s   +A A/.A/ N)__name__
__module____qualname____firstlineno____doc__r   r   r   rB   r   __static_attributes__rJ   r   r   r	   r	      s#    	5	s(TKr   r	   )r    bs4r   r#   r   r   r	   rJ   r   r   <module>rR      s>       " 	Z Z  Zr   