Updated README.md
This commit is contained in:
		
							parent
							
								
									8c8944b822
								
							
						
					
					
						commit
						56e97e1f46
					
				
							
								
								
									
										50
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								README.md
									
									
									
									
									
								
							@ -17,15 +17,16 @@ Usage
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Getting list of files inside torrent is straightforward:
 | 
					Getting list of files inside torrent is straightforward:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    import xbmc 
 | 
					```python
 | 
				
			||||||
    from torrent2http import State, Engine, MediaType
 | 
					import xbmc 
 | 
				
			||||||
    from contextlib import closing
 | 
					from torrent2http import State, Engine, MediaType
 | 
				
			||||||
 | 
					from contextlib import closing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Create instance of Engine 
 | 
					# Create instance of Engine 
 | 
				
			||||||
    engine = Engine(uri="...")
 | 
					engine = Engine(uri="...")
 | 
				
			||||||
    files = []
 | 
					files = []
 | 
				
			||||||
    # Ensure we'll close engine on exception 
 | 
					# Ensure we'll close engine on exception 
 | 
				
			||||||
    with closing(engine):
 | 
					with closing(engine):
 | 
				
			||||||
    # Start engine 
 | 
					    # Start engine 
 | 
				
			||||||
    engine.start()
 | 
					    engine.start()
 | 
				
			||||||
    # Wait until files received 
 | 
					    # Wait until files received 
 | 
				
			||||||
@ -35,25 +36,27 @@ Getting list of files inside torrent is straightforward:
 | 
				
			|||||||
        # Check if there is loading torrent error and raise exception 
 | 
					        # Check if there is loading torrent error and raise exception 
 | 
				
			||||||
        engine.check_torrent_error()
 | 
					        engine.check_torrent_error()
 | 
				
			||||||
        xbmc.sleep(200)
 | 
					        xbmc.sleep(200)
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Start streaming ###
 | 
					### Start streaming ###
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    import xbmc 
 | 
					```python
 | 
				
			||||||
    from torrent2http import State, Engine, MediaType
 | 
					import xbmc 
 | 
				
			||||||
    from contextlib import closing
 | 
					from torrent2http import State, Engine, MediaType
 | 
				
			||||||
 | 
					from contextlib import closing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # XBMC addon handle
 | 
					# XBMC addon handle
 | 
				
			||||||
    handle = ...
 | 
					handle = ...
 | 
				
			||||||
    # Playable list item
 | 
					# Playable list item
 | 
				
			||||||
    listitem = ...
 | 
					listitem = ...
 | 
				
			||||||
    # We can know file_id of needed video file on this step, if no, we'll try to detect one.
 | 
					# We can know file_id of needed video file on this step, if no, we'll try to detect one.
 | 
				
			||||||
    file_id = None
 | 
					file_id = None
 | 
				
			||||||
    # Flag will set to True when engine is ready to resolve URL to XBMC
 | 
					# Flag will set to True when engine is ready to resolve URL to XBMC
 | 
				
			||||||
    ready = False
 | 
					ready = False
 | 
				
			||||||
    # Set pre-buffer size to 15Mb. This is a size of file that need to be downloaded before we resolve URL to XMBC 
 | 
					# Set pre-buffer size to 15Mb. This is a size of file that need to be downloaded before we resolve URL to XMBC 
 | 
				
			||||||
    pre_buffer_bytes = 15*1024*1024
 | 
					pre_buffer_bytes = 15*1024*1024
 | 
				
			||||||
    engine = Engine(uri="...")
 | 
					engine = Engine(uri="...")
 | 
				
			||||||
    with closing(engine):
 | 
					with closing(engine):
 | 
				
			||||||
    # Start engine and instruct torrent2http to begin download first file, 
 | 
					    # Start engine and instruct torrent2http to begin download first file, 
 | 
				
			||||||
    # so it can start searching and connecting to peers  
 | 
					    # so it can start searching and connecting to peers  
 | 
				
			||||||
    engine.start(file_id or 0)
 | 
					    engine.start(file_id or 0)
 | 
				
			||||||
@ -101,6 +104,7 @@ Getting list of files inside torrent is straightforward:
 | 
				
			|||||||
        # Wait until playing finished or abort requested
 | 
					        # Wait until playing finished or abort requested
 | 
				
			||||||
        while not xbmc.abortRequested and xbmc.Player().isPlaying():
 | 
					        while not xbmc.abortRequested and xbmc.Player().isPlaying():
 | 
				
			||||||
            xbmc.sleep(500)
 | 
					            xbmc.sleep(500)
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
### Fully working example ###
 | 
					### Fully working example ###
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user